How to restore data on edit form implemented by Bootstrap3 modal

Bing Lan

I am working on a project which uses bootstrap3 to implement a modal containing edit form. I can display the modal and load original data into each input field by setting the value attribute. The problem is when I make some change and click Close button to cancel it. Then load this edit form again and see the content is what edited last time not the original one. I do not know how to restore it on clicking the Close button. Besides, where is the user input stored in modal? Below is my code

<div class="span4">
            <div class="panel panel-primary">
                <div class="panel-heading">qawsedrftgDI</div>
                <div class="panel-body">jhyuh</div>
            </div>
            <p>
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#editItem2">Edit</button>
                <input type="button" class="btn btn-default" value="Delete" onclick="javascript:deleteCategoryNoneItem(2);" />
            </p>
            <div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" id="editItem2">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">Make Your Change</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-horizontal" method="POST" id="existingItem2">
                                <div class="form-group">
                                    <label class="control-label col-md-2">Title</label>
                                    <div class="col-md-8">
                                        <input type="text" class="form-control" value="qawsedrftgDI" id="title2" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-2">Content</label>
                                    <div class="col-md-8">
                                        <textarea rows="10" class="form-control" id="content2">jhyuh</textarea>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                            <button type="button" class="btn btn-primary" id="changeExistingItem" onclick="javascript:modifyCategoryNoneItem(2);">Save changes</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
ndcweb

See the documentation for Bootstrap modals. In the event section you can use "hidden.bs.modal" event to do some stuff after the modal is closed. So it can look like:

$('#myModal').on('hidden.bs.modal', function (e) {
  $(this).find('input').val('');
});

From here you can specify "placeholder" attributes on input fields, or do some javascript in the event handler.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use bootstrap modal to edit data in CodeIgniter

From Dev

How to make an "Edit User" form inside Bootstrap Modal using JQUERY?

From Dev

Edit Table Row Data in Modal Form

From Dev

How to pass form data from angular ui bootstrap modal to view

From Dev

How to pass Bootstrap Modal form data to Spring Boot controller

From Dev

How to style form inside modal with Bootstrap 3

From Dev

Laravel 5.0 data Insertion using bootstrap3 form

From Dev

how to setup bootstrap form in a modal

From Dev

customizing jqgrid modal edit form

From Dev

How gaps are made between form elements in bootstrap3?

From Dev

get data From Bootstrap 3 modal form with jquery ajax

From Dev

Display specific row data in bootstrap modal with edit button click

From Dev

AngularJS Edit Data/Form

From Dev

How to GET values from Bootstrap Modal form?

From Dev

How to validate a form in a bootstrap modal window in wicket?

From Dev

bootstrap3 tooltip in a form

From Dev

Bootstrap 3 modal form not appearing

From Dev

Bootstrap 3 modal form not appearing

From Dev

How to show my customaized alert box over bootstrap3 modal box?

From Dev

Bootstrap modal in modal form issue

From Dev

bootstrap modal for edit user profile

From Dev

Fire a remote bootstrap modal when clicking a form submit button, remote modal content then has form data to be displayed?

From Dev

Call back function in modal of bootstrap3

From Dev

Call back function in modal of bootstrap3

From Dev

How to edit form with data from database tables in laravel

From Dev

How do you pass object data into textboxes in a second form to edit?

From Dev

How to get particular rows data in form again to edit

From Dev

How to edit form with data from database tables in laravel

From Dev

AngularJS & Bootstrap modal Form. Why data is getting submitted on cancel

Related Related

  1. 1

    How to use bootstrap modal to edit data in CodeIgniter

  2. 2

    How to make an "Edit User" form inside Bootstrap Modal using JQUERY?

  3. 3

    Edit Table Row Data in Modal Form

  4. 4

    How to pass form data from angular ui bootstrap modal to view

  5. 5

    How to pass Bootstrap Modal form data to Spring Boot controller

  6. 6

    How to style form inside modal with Bootstrap 3

  7. 7

    Laravel 5.0 data Insertion using bootstrap3 form

  8. 8

    how to setup bootstrap form in a modal

  9. 9

    customizing jqgrid modal edit form

  10. 10

    How gaps are made between form elements in bootstrap3?

  11. 11

    get data From Bootstrap 3 modal form with jquery ajax

  12. 12

    Display specific row data in bootstrap modal with edit button click

  13. 13

    AngularJS Edit Data/Form

  14. 14

    How to GET values from Bootstrap Modal form?

  15. 15

    How to validate a form in a bootstrap modal window in wicket?

  16. 16

    bootstrap3 tooltip in a form

  17. 17

    Bootstrap 3 modal form not appearing

  18. 18

    Bootstrap 3 modal form not appearing

  19. 19

    How to show my customaized alert box over bootstrap3 modal box?

  20. 20

    Bootstrap modal in modal form issue

  21. 21

    bootstrap modal for edit user profile

  22. 22

    Fire a remote bootstrap modal when clicking a form submit button, remote modal content then has form data to be displayed?

  23. 23

    Call back function in modal of bootstrap3

  24. 24

    Call back function in modal of bootstrap3

  25. 25

    How to edit form with data from database tables in laravel

  26. 26

    How do you pass object data into textboxes in a second form to edit?

  27. 27

    How to get particular rows data in form again to edit

  28. 28

    How to edit form with data from database tables in laravel

  29. 29

    AngularJS & Bootstrap modal Form. Why data is getting submitted on cancel

HotTag

Archive