Java Script in Rails 3.1 works only in certain parts. Any idea why?

Go To StackoverFlow.com

0

This might seem a bit weird, but since I am new in RoR and cannot find any similar questions I thought you might know. The situation is that JavaScript does not work throughout my whole site. For instance. For the sake of checking, I place a link with an alert function in the footer. It did not work at the beginning, it felt like the JS was disabled(but it wasn't). But eventually it worked. Now it works in most the pages but it does not work in one that there is also an 'autocomplete' field. Of course, this autocomplete field does not work either. That could lead you to think that there is something wrong with the autocomplete code. However this same code is working in the sidebar.

Any ideas why?

Could it have anything to do with the fact that one day my assets folder appeared empty? After installing the gmaps4rails gem I realized that all my Js and CSS files were gone from my assests folder. Ok, it might have happened long before and I just realized at that point. I don't really know.

Here in the root you can see that the 'Hola sip' click at the button works. here it works However, here same link does not trigger the alert function. here it doesn't

2012-04-04 16:49
by Sergio Nekora
welcome to stackoverflow, this is really hard to debug as it is, please post some code or post a link to the url where this happen - isJustMe 2012-04-04 16:51
Thanks for the welcoming!! As suggested I added 2 links. Hope that clarifies a bit - Sergio Nekora 2012-04-04 17:27
I don't know the cause, but in the unworking link there is a JavaScript error when the page is loaded. That is probably why the alert is not being triggered - Dave Isaacs 2012-04-04 17:32
If a javascript fails with an exception when loading some script, the javascript on the rest of the page might not work as expected. Make sure you have no exceptions via Console - Sairam 2012-04-04 17:55
1.How can it give an error when the JS file is the same? 2.How do you know it gives an error? I mean, how can you see that? Anyway, I will have a look at that. Thanks - Sergio Nekora 2012-04-04 18:11
I used Firefox with the FireBug plug-in to see the JavaScript error - Dave Isaacs 2012-04-04 18:28


0

In IE at least, if any errors occur in your page javascript stops. So if certain things inexpplicably stop working, it's a sign that you caused an error and stopped javascript.

Have a good look at the developer toolbar for IE, or the built-in development tools in Firefox or Chrome, or Firbug for Firefox. These tools all have a way of telling you all about any javascript errors have occurred in your page. Make good use of them.

2012-04-04 19:12
by Michael Slade
I am gonna have a look at that. I will post as soon as I find anything interesting. Thanks - Sergio Nekora 2012-04-04 21:29
Ads