[Rails] Re: Jquery strange behavior
Barry wrote in post #1101300:
> But for the sake of stupid errors in simple things I'll post jquery
> code:
>
> $('.keyword_links').ready(function(){
> var keywords = $('.keyword_links');
> function addField(){
> alert('True');
> }
> keywords.bind("click", addField);
> });
What you show here is not the proper way to use the ready AFAIK.
Try this instead:
$(document).ready(function() {
$('.keyword_links').bind('click', addField);
});
function addField() {
alert('True');
}
// Or the shorthand version
$(function() {
$('.keyword_links').click(function() { alert('True') });
});
// Even more awesome use CoffeeScript
$ -> $('.keyword_links').click -> alert('True')
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home