Support » Plugin: Easy Modal » Add a function onto the close button using jquery

  • Hi,
    I want to know how to attach a function onto the close button to empty the contents of the modal on close. I have tried this

    jQuery(document).ready(function($){
        $("a.close-modal").click(function(){
           $("div#user-input").empty();
        });
      });

    but nothing happens. Any help would be wonderful. I don’t have a live link to my page as it is currently on a dev site.

    http://wordpress.org/plugins/easy-modal/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Daniel Iser

    (@danieliser)

    Not sure what you are trying to do. Assuming you want to clear inputs so the user can have a blank form?

    If so then try
    $('input').val('');

    If you want to remove the content of that div then just use
    $("div#user-input").html('');

    Hope this helps.

    Thread Starter johnmartelle

    (@johnmartelle)

    Basically when I launch the modal I have a jquery script that creates form elements in a div. What I want to do is when you click the exit button to close the modal I want to clear all the form inputs.

    Plugin Author Daniel Iser

    (@danieliser)

    Then what you want is to clear the values of the inputs so you need to do something like

    $('input,select').val(''); $('textarea').text('');

    Hope this helps..

    Please take a moment to rate and review the plugin and/or support. http://wordpress.org/support/view/plugin-reviews/easy-modal

    Thread Starter johnmartelle

    (@johnmartelle)

    Still having problems with this issue. I know how to reset my form fields and have done it with a link. I want to however accomplish this same action using the close button of the modal. I have tried using the selector $("a.close-modal") along with the .click() jquery event but nothing happens.

    Plugin Author Daniel Iser

    (@danieliser)

    You will probably need to override the default functionality like so.

    $("#eModal-1 .close-modal").click(function(e){
        e.preventDefault();
        // Your code here
        $("eModal-1").emodal("close");
    })
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add a function onto the close button using jquery’ is closed to new replies.