Override default javascript functionality with jQuery -
i trying overwrite javascript on change event in below code jquery believe inline javascript taking priority on jquery functionality declared. trying have ajax version of site includes additional javascript file. need functionality still work without additional ajax version, not sure whether should include in main javascript file or leave inline right now. suggestions , information regarding them appreciated! thanks!
<form action="/cityhall/villages/" method="post" name="submit_village"> <select name="village" onchange="document.submit_village.submit();"> <option value=""></option> </select> </form> i trying use jquery form plugin submit posts php handle requests follows:
var bank_load_options = { target: '#content', beforesubmit: showrequest, success: showresponse }; $('form.get_pages').livequery(function(){ $(this).ajaxform(bank_load_options); return false; }); i modified code following:
<form action="/cityhall/villages/" method="post" id="submit_village" name="submit_village"> <select name="village" class="get_pages" rel="submit_village"> <option value=""></option> </select> </form> <script> # main javascript $('.get_pages').live('change',function(e){ var submit_page = $(this).attr('rel'); $("#"+submit_page).submit(); }); # ajax javascript var bank_load_options = { target: '#content', beforesubmit: showrequest, success: showresponse }; $('.get_pages').live('change',function(){ var submit_page = $(this).attr('rel'); $("#"+submit_page).ajaxform(get_pages_load_options); return false; }); </script> however runs every other option when change it.
it practice have javascript in 1 place (not 1 file specifically, not half inline, half in file), such remove inline javascript.
this priority issue can manage same location.
Comments
Post a Comment