wordpress doesn't register custom jquery -


i have wordpress site , wish add custom chunk of jquery code site. code below meant trigger when user selects radio button, linking change change within page. dom generated puts ids on elements , proceeded bind events elements. problem events trigger when looking in firebug, functions don't triggered.

i've tried to:

  • put event bindings inside document ready...
  • outside document ready...
  • added script in header....
  • added script footer ...
  • using both shorthand '$' , jquery when calling event
  • tried e.preventdefault() method

and every method has same result, function not trigger. i've tried different events (click, select, change...) no luck.

here's script:

<script> jquery(document).ready(function($) { var processing = false; $('#shipping_method_local_delivery').click(function(e){             e.preventdefault();             alert("this click");         });  $('#payment_method_rba_etomitreba').change(function(){     if (processing) {return;}     processing = true;     $('#shipping_method_local_delivery').click();     processing = false; });  $('#shipping_method_local_pickup').change(function(){     if (processing) {return;}     processing = true;       $('#payment_method_cod').click();     processing = false; });  $('#payment_method_cod').change(function(){     if (processing) {return;}     processing = true;     $('#shipping_method_local_pickup').click();     processing = false; });  $('#payment_method_bacs').change(function(){     if (processing) {return;}     processing = true;     $('#shipping_method_local_delivery').click();     processing = false; }); }); </script> 

odds selectors not returning dom elements when being run. can happen if elements being created set of javascript/jquery.

using firebug, set breakpoint @ first attempt bind event handler, , in watch window set watch jquery selector, , see if array 0 or populated.

if dom elements being created afterwards, may want @ using jquery on method http://api.jquery.com/on/ . can bit tricky wrap mind around...but once got code should work no issues.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -