Plugin Settings page reload



  • Hi All, I am writing a custom plugin to display 4 curated categories on the home page, I am able to display them correctly, on the plugin settings page I have on click event on Save settings button to check only unique categories are selected, but the issue is when ever I visit the settings page - the DOM does not recognize the on click function and just reloads . Once the settings page is reloaded - the on click function on save button works.

    I am not sure how to go about this,
    Here is the code in app.js
    require(['settings'], function(settings) {
    settings.sync('plugin', $('#categories'));

    $('#save').click( function (event) {
    });
    });


  • Global Moderator

    You need to run event.preventDefault() to prevent the Click from automatically submitting the form


 

| |