Click here to Skip to main content
16,021,181 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I have a bootstrap modal in my asp.net mvc code that it's body bind in runtime. first time I click on the some button and modal work good (body return from controller by jquery ajax).

then must change model’s body dynamically , it works good too(by jquery Ajax and json). then I close modal. second time I click on some button , modal work but with problem . the problem is scrollbar of modal's body is enable but not working , like that the modal is lock . this problem is in chrome , but in IE I have not that. my code for modal :

success: function (response) {
$('#myModal').html(response);
$('#myModal').modal({ show: true, backdrop: false, keyboard: false });


I change css : overflow:hidden and position:fix but it's not work
Posted
Updated 1-Oct-13 19:43pm
v2

Does your responce contain the entire modal structure?

Cause on this line

<br />
$('#myModal').html(response);<br />


You will be changing the entire modal structure, for example, if your modal structure is

HTML
<div class="modal hide fade" id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Modal header</h3>
  </div>
  <div class="modal-body">
    <p>One fine body…</p>
  </div>
  <div class="modal-footer">
    <a href="#" class="btn">Close</a>
    <a href="#" class="btn btn-primary">Save changes</a>
  </div>
</div>

When your code runs, and your response is "Query successful" then, your modal structure becomes
HTML
<div class="modal hide fade" id="myModal">
    Query successful
</div>


You should be specific on the part of the DOM you want to change, try
$('#myModal.modal-body').html(response);
 
Share this answer
 
v2
Great, It worked for me,

$('#myModal.modal-body').html(response);

thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900