currently i have an link as mentioned in below format
<%= link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo("update", "notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
i would like to apply toggle functionality on update could anyone开发者_Python百科 please help me.
There are numerous possibilities to achieve a toggle button. You may choose to change the JavaScript function your button executes, or the function may toggle the Rails action to call. I personally would go for a Rails action that knows how to toggle itself:
def toggle_action
@model = Model.find param[:id]
if @model.active?
@model.active = false
render :js => "alert('Active!');"
else
@model.active = true
render :js => "alert('Inactive!');"
end
end
精彩评论