<%= javascript_include_tag "jquery.js" %> I want to add class to table tag using following command inside script tag. <script> (document).ready( function() { $(''tr:odd'').addclass(''odd''); $(''tr:even'').addclass(''even''); alert("abc''); // for debugging $(''th'').parent().addclass(''table-heading''); } ); </script> CSS has all the tree class declared .odd { background-color: #fcc; } .even { background-color: #cef; } .table-heading { font-size: 12px; } CSS is linked properly and if I add class manually I can see the stylesheet applied to the page. But I cannot get the alert neither I can see the class in <tr> tag. I am a newbie to rails. any help is appreciated. Thanks in advance
On Wed, Apr 29, 2009 at 11:39 PM, Anil <virappan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > <%= javascript_include_tag "jquery.js" %>Shouldn''t that be <%= javascript_include_tag ''jquery'' %> You could probably easily discover whether your jquery file is being loaded by using Firebug, btw.... HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Thanks Hassan Schroeder, The File is loaded correctly. And I tried both <%= javascript_include_tag ''jquery'' %> <%javascript_include_tag "jquery.js" %> And both load the file correctly. Moreover I can see the JavaScript (JQuery.js) loaded using firebug. Still No luck. Thanks On Apr 30, 7:14 am, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Apr 29, 2009 at 11:39 PM, Anil <virap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > <%= javascript_include_tag "jquery.js" %> > > Shouldn''t that be <%= javascript_include_tag ''jquery'' %> > > You could probably easily discover whether your jquery file is being > loaded by using Firebug, btw.... > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
On Thu, Apr 30, 2009 at 9:58 AM, Anil <virappan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Oh, wait --> <script> > (document).ready( function() {S/B <script type="text/javascript"> // not THE problem, but invalid otherwise $(document).ready( ... Try that... -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Are you sure you are not including prototype.js? On Apr 29, 11:39 pm, Anil <virap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> <%= javascript_include_tag "jquery.js" %> > > I want to add class to table tag using following command inside > script tag. > <script> > (document).ready( function() { > $(''tr:odd'').addclass(''odd''); > $(''tr:even'').addclass(''even''); > alert("abc''); // > for debugging > $(''th'').parent().addclass(''table-heading''); > } > ); > > </script> > > CSS has all the tree class declared > .odd { > background-color: #fcc; > > } > > .even { > background-color: #cef; > > } > > .table-heading { > font-size: 12px; > > } > > CSS is linked properly and if I add class manually I can see the > stylesheet applied to the page. > > But I cannot get the alert neither I can see the class in <tr> tag. > > I am a newbie to rails. > any help is appreciated. > > Thanks in advance
yeah, if you still have javascript_include_tag :defaults, prototype will still get loaded If you want to keep prototype loaded though (to take advantage of Rails builtin AJAX functionality for example), http://docs.jquery.com/Using_jQuery_with_Other_Libraries will be of use On Apr 30, 2:13 pm, Brendon <bren...-gi94QSVkwfGt/hvpvFFPbQ@public.gmane.org> wrote:> Are you sure you are not including prototype.js? > > On Apr 29, 11:39 pm, Anil <virap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > <%= javascript_include_tag "jquery.js" %> > > > I want to add class to table tag using following command inside > > script tag. > > <script> > > (document).ready( function() { > > $(''tr:odd'').addclass(''odd''); > > $(''tr:even'').addclass(''even''); > > alert("abc''); // > > for debugging > > $(''th'').parent().addclass(''table-heading''); > > } > > ); > > > </script> > > > CSS has all the tree class declared > > .odd { > > background-color: #fcc; > > > } > > > .even { > > background-color: #cef; > > > } > > > .table-heading { > > font-size: 12px; > > > } > > > CSS is linked properly and if I add class manually I can see the > > stylesheet applied to the page. > > > But I cannot get the alert neither I can see the class in <tr> tag. > > > I am a newbie to rails. > > any help is appreciated. > > > Thanks in advance
The problem was the case of addClass. Changing addclass to addClass did the trick. Thank you very much guys for all your help. -Anil On Apr 30, 11:37 am, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yeah, if you still have javascript_include_tag :defaults, prototype > will still get loaded > > If you want to keep prototype loaded though (to take advantage of > Rails builtin AJAX functionality for example),http://docs.jquery.com/Using_jQuery_with_Other_Librarieswill be of > use > > On Apr 30, 2:13 pm, Brendon <bren...-gi94QSVkwfGt/hvpvFFPbQ@public.gmane.org> wrote: > > > Are you sure you are not including prototype.js? > > > On Apr 29, 11:39 pm, Anil <virap...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > <%= javascript_include_tag "jquery.js" %> > > > > I want to add class to table tag using following command inside > > > script tag. > > > <script> > > > (document).ready( function() { > > > $(''tr:odd'').addclass(''odd''); > > > $(''tr:even'').addclass(''even''); > > > alert("abc''); // > > > for debugging > > > $(''th'').parent().addclass(''table-heading''); > > > } > > > ); > > > > </script> > > > > CSS has all the tree class declared > > > .odd { > > > background-color: #fcc; > > > > } > > > > .even { > > > background-color: #cef; > > > > } > > > > .table-heading { > > > font-size: 12px; > > > > } > > > > CSS is linked properly and if I add class manually I can see the > > > stylesheet applied to the page. > > > > But I cannot get the alert neither I can see the class in <tr> tag. > > > > I am a newbie to rails. > > > any help is appreciated. > > > > Thanks in advance > >