[support] Problem with javascript and views
Michel Morelli
michel at ziobuddalabs.it
Wed Jun 17 15:39:04 UTC 2009
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.
--
Michel 'ZioBudda' Morelli michel at ziobuddalabs.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
http://www.ziobudda.net ICQ: 58351764
http://www.ziobuddalabs.it Skype: zio_budda
http://www.ziodrupal.net MSN: michel at ziobuddalabs.it
JABBER: michel at ziobuddalabs.it
More information about the support
mailing list