Generic-user-small RC 19 posts

I’ve been playing around with facebooker’s ‘link_to_remote’ helper for an hour and I just can’t set the :class attribute. In firebug the ‘class’ setting just doesn’t show up like it’s supposed to. Below is the code:

1.) <%= link_to_remote( “Create”, :class => ‘foo’, :update => ‘container’, :url => ajax_create_url(:canvas => false, :id=> 3) %>

however the :class attribute gets set if the :url attribute is set without the facebooker url helper, like so:

2.) <%= link_to_remote( “Create”, :class => ‘foo’, :update => ‘container’, {:url => { :controller => “foo”, :action => “ajax_create”, :id => 3 }} %>

Although the ‘class’ attribute gets set in the second approach it causes Ajax errors.

Does anyone know what’s causing the problems in the first approach? And are there workarounds to this?

 
Head_small Mike Mangino 310 posts

I think you have the options backwards. It should be:


link_to_remote("Create",{:url=>ajax_create_url(...)},{:class=>"foo"})

There are two hashes so you need to use the braces around both.

 
Generic-user-small RC 19 posts

Mike, I tried your approach and two problems still persist:

1.)The class attribute still does not get set. It seems like link_to_remote doesn’t read this option specifically when the facebooker url helper is used.

2.) if the :update option is added an error is returned: ‘wrong number of arguments (4 for 3)’. Here is the code I was testing:

link_to_remote("Create",{:url=>ajax_create_url(:canvas => false, :user_id=> 3)},{:class=>"foo"}, {:update => 'bar'})

It seems like the facebooker url helper deprecates a lot of the original options that link_to_remote could take. Is there a workaround, short of going under the hood and making changes to the facebooker library?

 
Head_small Mike Mangino 310 posts

I think update goes in with :url. The other is just a bug. It might be an easy fix to Facebooker. I would ask on the mailing list if anyone has that working.

Mike

 
Generic-user-small RC 19 posts

Thanks for the help Mike.

5 posts, 2 voices