• scottsawyer

    (@scottsawyer)


    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.

    https://www.ads-software.com/plugins/siteorigin-panels/

Viewing 1 replies (of 1 total)
  • Thread Starter scottsawyer

    (@scottsawyer)

    Ok, well, something new. If I add the widget, save the form ( though unconfigured ), update the page, edit the widget, all the js works. So, my problem seems to only occur when first adding the widget.

    While I’d like to get this problem totally resolved, this will work for me at the moment. I’ve got two – three weeks before any clients will have to use this feature.

    Please let me know if you have any great ideas.

Viewing 1 replies (of 1 total)
  • The topic ‘jQuery not working ( no error ) in custom widget’ is closed to new replies.