Hi. I have a view with some filter exported. I have add a <span> to the filter exported's form so that when the user click on this <span> my JS function is called.
This is the code:
function mymodule_form_alter(&$form,&$fs,$form_id) { if ($form_id == 'views_exposed_form') {
$form['export'] = array( '#type' => 'item', '#prefix' => '<span id="edit-export">', '#suffix' => '</span>', '#value' => t('Export') ); drupal_add_js(drupal_get_path('module','mymodule')."/js/myjsfile1.js"); } }
This is the JS code:
$(document).ready(function() { $('#edit-export').click(function () { var nItem = $('#edit-language')[0].selectedIndex; var lang = $('#edit-language')[0].options[nItem].value;
var regione = $('#edit-field-statename-value').attr('value'); var provincia = $('#edit-field-county-value').attr('value');
alert(lang + ' -- ' + regione + ' -- ' + provincia); return false; }); });
Now the problem: If I load the page and press on the <span> element my JS function is called and it works. If I change 1 of the exposed filter and exec the view (click on the submit button) my javascript file doesn't work anymore. Where is my problem ?
M.