Muhammad Umar
Muhammad Umar

Reputation: 237

After close modal not remove fillable data

I am working with bootstrap modal when i fill data on form after that i close reopen it but modal still have value. I am using jquery code

 $(document).ready(function () {
   $('body').on('hidden.bs.modal', '.modal', function (event) {
     console.log('testhahah');
     $(this).removeData('bs.modal');
      });
 });

above code is not working. My jsfiddle is https://jsfiddle.net/pp7dj2ab/2/

Upvotes: 0

Views: 32

Answers (1)

phobia82
phobia82

Reputation: 1257

jQuery.removeData() wont reset the form, this function is to:

The jQuery.removeData() method allows us to remove values that were previously set using jQuery.data(). When called with the name of a key, jQuery.removeData() deletes that particular value; when called with no arguments, all values are removed.

You should use Form reset() Method

$(this).find('form')[0].reset();

https://jsfiddle.net/pp7dj2ab/3/

Upvotes: 1

Related Questions