How would one go about changing the href="#" of a link_to_remote tag, and furthermore - how would one go about getting rid of the return false; in the onclick event. Would it be wiser to simply write a new remote linking helper? Thanks. -- Kyle Neath kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://www.neathdesign.com
I''m not sure I understand what you''re asking for - if you change the href from "#", surely it will be a normal link - and rather than invoking your ajax controller method, it''ll take you to a new page. sam On 6/20/05, Kyle Neath <kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How would one go about changing the href="#" of a link_to_remote tag, > and furthermore - how would one go about getting rid of the return > false; in the onclick event. Would it be wiser to simply write a new > remote linking helper? > > Thanks. > -- > Kyle Neath > kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > http://www.neathdesign.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- sam http://www.magpiebrain.com/
>On 6/20/05, Kyle Neath <kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>How would one go about changing the href="#" of a link_to_remote tag, >>and furthermore - how would one go about getting rid of the return >>false; in the onclick event. Would it be wiser to simply write a new >>remote linking helper? >> > Sam Newman wrote: > >I''m not sure I understand what you''re asking for - if you change the >href from "#", surely it will be a normal link - and rather than >invoking your ajax controller method, it''ll take you to a new page. > > >As long as the return false is still in the JS link, then the ajax will be invoked instead of the URL href. However, if the user does not have JS enabled in their browser, then they will follow the link instead. Having a href link and the JS is good to be backwards compatible with clients which either do not have JS capability, or have it turned off. Maybe this is what the OP is after? Although not sure why you would want to remove the ''return false''. Maybe link_to_remote (or another helper) should have the ability to link to an alternative controller/action to make it easy to code for a fallback for this backwards compatibility? (This may be possible already, I haven''t checked) -- R.Livsey www.livsey.org
> Maybe link_to_remote (or another helper) should have the ability to link > to an alternative controller/action to make it easy to code for a > fallback for this backwards compatibility? (This may be possible > already, I haven''t checked)It seems that it already has this. You can specify an :href param like so: <%= link_to_remote("Works without JavaScript, too...", { :update => ''mydiv'', :url => { :action => :say_hello } }, { :href => url_for( :action => :say_hello ) } ) %> (Found this in the Rails Book Beta 2 -- hope the authors don''t mind me reproducing it!) Incidentally, you can also specify an :html param to the form_remote_tag, which will allow your form to fall back to a ''traditional'' submit. <%= form_remote_tag( :update => "update_div", :url => { :action => :guess }, :html => { :action => url_for( :action => :guess ), :method => ''post'' } ) %> <% # ... %> <%= end_form_tag %> Hope this helps.... J
Ah cool, looks like that example will work! For those interested: It''s not in having "traditional" links, but rather linkable ajax pages. I have a page where clicking one of many links shows different content. I would like to link to these with a unique #anchor tag. Using this, I can then take javascript and select the proper content. On 6/20/05, James Fairbairn <jfairbairn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Maybe link_to_remote (or another helper) should have the ability to link > > to an alternative controller/action to make it easy to code for a > > fallback for this backwards compatibility? (This may be possible > > already, I haven''t checked) > > It seems that it already has this. You can specify an :href param like so: > > <%= link_to_remote("Works without JavaScript, too...", > { :update => ''mydiv'', :url => { :action => :say_hello } }, > { :href => url_for( :action => :say_hello ) } ) %> > > (Found this in the Rails Book Beta 2 -- hope the authors don''t mind me > reproducing it!) > > Incidentally, you can also specify an :html param to the > form_remote_tag, which will allow your form to fall back to a > ''traditional'' submit. > > <%= form_remote_tag( > :update => "update_div", > :url => { :action => :guess }, > :html => { > :action => url_for( :action => :guess ), > :method => ''post'' } ) %> > <% # ... %> > <%= end_form_tag %> > > > Hope this helps.... > > J > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Kyle Neath kneath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://www.neathdesign.com