On 05/05/2011 08:41 AM, Jeffrey L. Taylor wrote:
function replace_article(id, action) {
   obj = $j('#article_'+id);
   jQuery.ajax({url: '/articles/'+action+'/'+id,  type: 'POST',
                  data: {_method: 'put'},
                  success: function(data){obj.replaceWith(data);}
              });
}


Jeffrey

Look closely at your function, what is the scope of the variable named obj? Ask yourself what happens when multiple calls to replace article are sharing a global reference to obj because you forgot to say var obj.

--
Ramon Leon

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to