WordPress.org

Forums

Easy Modal
Add a function onto the close button using jquery (6 posts)

  1. johnmartelle
    Member
    Posted 1 year ago #

    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/

  2. danieliser
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. johnmartelle
    Member
    Posted 1 year ago #

    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.

  4. danieliser
    Member
    Plugin Author

    Posted 1 year ago #

    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

  5. johnmartelle
    Member
    Posted 1 year ago #

    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.

  6. danieliser
    Member
    Plugin Author

    Posted 1 year ago #

    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");
    })

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Easy Modal
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.