jquery - Check box triggering remote link -


i in process of converting link check box.

i take this

<%= link_to (image_tag "table.png", :alt => "show area(s) table", :style => "padding-left:15px;", :id => "updateareatableiconid"), refresh_area_table_path({:field_id => "#{@field.id}"}), :remote => true %>  

and create this

<input type='checkbox' id='showareabox' onclick='showarea(); <%= redirect_to refresh_area_table_path({:field_id => "#{@field.id}"}), :remote => true %>;'></input>      

so in other words want rid of link , add redirect onclick of checkbox

if there way trigger remote redirect in jquery add showarea(); method well.

thanks!

it sounds want programmatically click anchor whenever checkbox checked?

here's 1 way it:

var mylink = $('#mylinkid'); // assumes have reference <a/> element  $('#showareabox').change(function() {      // if checkbox checked, invoke link     if( this.checked ) {         mylink.trigger('click');     }      // checkbox unchecked     // else {} }); 

Comments