El Tuesday 16 December 2008 16:56:07 harv escribió:
> Thanks, but this doesn't really get at what I'm after.
> I don't want the link to submit to a controller/action but just to the
> JS function. The JS function will then submit to the controller/
> action.
> I've played around with the above suggestions but cannot get to a
> point of having the link *just* respond to the onclick event and not
> invoke the backend action.
try with :page => true, :html_options => {:onclick => 'doWhatIWant(105)'}
If it doesn't work try to add :href => '#' to html_options
>
> Am I trying to push ActionScaffold beyond the reasonable limits of its
> flexibility?
>
> Thanks
>
> On Dec 15, 6:30 am, "Sergio Cambra .:: entreCables - Symbol Servicios
>
> Informáticos S.L. ::." <[email protected]> wrote:
> > El Friday 12 December 2008 22:11:45 harv escribió:
> > > I currently add some custom links *above* an active scaffold using a
> > > method from a plugin like this:
> > >
> > > <%= plugin_method_creates_links({:id => section.id}) %>
> > > <%= render :active_scaffold => 'section', :label => "Section"} %>
> > >
> > > So the links generated by the plugin are completely separate from the
> > > scaffold, but act upon the data the scaffold does.
> > >
> > > These links have an onClick() event that calls a JavaScript function -
> > > something like...
> > > <a ... onClick(javascript:doWhatIWant(105))>Do</a>
> > > ...where the 105 comes from the :id param passed into the
> > > plugin_method_creates_links() method
> > >
> > > What I really need is to have these links appear *next to* the
> > > standard scaffold "Create" link, within the scaffold.
> > >
> > > I looked at the action_links docs, but see no way to invoke the plugin
> > > method I need to use. For that matter, I don't see how to use them to
> > > create the links I need at all - even if I forget the plugin and do it
> > > myself. I don't see how to say "I want the onClick event of this link
> > > to call the doWhatIWant() JS function, passing in the current
> > > section's id.
> > >
> > > Can anyone suggest how I might proceed?!
> > >
> > > I was looking at overrides - is there a way overrides could be used
> > > here. It doesn't look like it to me.
> >
> > Usually the best is a link to an action which responds to html and ajax
> > requests:
> > config.action_links.add 'action_name', :type => :table, :parameters =>
> > {:id => 105}
> > In your controller use respond_to to render a different response to html
> > and ajax requests.
> >
> > You can use html_options to set onclick too:
> > config.action_links.add 'action_name', :type => :table, :html_options =>
> > {:onclick => "doWhatIWant(105)"}
> >
> > --
> > Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
> > Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > T) 902 021 404 F) 976 52 98 07 E) [email protected] Hide quoted
> > text -
> >
> > - Show quoted text -
>
>
--
Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---