jQuery not working ( no error ) in custom widget
-
Thanks for the plugin.
I created a little plugin that exposes a widget that I am trying to load into my page builder post. The widget form uses ajax to load additional options. The ajax works great on the Widgets page, but when I try to add the widget to the page builder page, it doesn’t work. I know I am doing it wrong, but would appreciate your help.
Things I’ve observed / tried.
The jquery does load, and when I just put an alert at the top, it fires.
When I try to react to an event, the listener doesn’t pick up on it.
No errors in the console.
My form is a bunch of select boxes with classes.So, this is sort of what I am trying to do.
function form( $instance ) { ?> <select class="my-awesome-widget-box-1"><option /><option /><option /></select> <?php } function form_js(){ ?> <script> jQuery(document).ready(function(){ alert( 'here' ); // works on page load jQuery('.my-awesome-widget-box-1').on( 'change', function() { alert( 'CHANGED' ); // never fires }); jQuery('.my-awesome-widget-box-1').bind( 'change', function() { alert( 'CHANGED' ); // never fires }); jQuery('.my-awesome-widget-box-1').change( function() { alert( 'CHANGED' ); // never fires }); }); </script> <?php }
Sorry for the terse code, I didn’t want to load the entire plugin here, but let me know if you need to see more.
- The topic ‘jQuery not working ( no error ) in custom widget’ is closed to new replies.