在$(document).ready()中,我生成一個模型彈出框以在頁面上添加項目,並且它在第一次加載頁面時工作正常,但如果它再次不顯示模式彈出框至少被調用一次,所以請告訴我我在做什麼錯誤的地方,它不顯示模態視圖?
OR
請問jQuery的ready()被調用一次頁面加載時?
這裏是jQuery的:
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function (e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set heigth and width to mask to fill up the whole screen
$('#mask').css({ 'width': maskWidth, 'height': maskHeight });
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow", 0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2 - $(id).height()/2);
$(id).css('left', winW/2 - $(id).width()/2);
//transition effect
$(id).fadeIn(2000);
// replacing text of divErrorMsg
var htmlStr = $("#divErrorMsg").html();
if (htmlStr != null && htmlStr.length > 0) {
htmlStr = null;
$("#divErrorMsg").text('');
}
});
});
,這裏是哪裏彈出被稱爲鏈接:
<a name="modal" href="#iPopup" class="button smallButton">Add Item</a>
和iPopup:
<div id="Popups">
<div id="iPopup" class="popup">
<a class="closeButton">x</a>
<div class="popupContent">
<h3>Choose a question type</h3>
<ul class="chooseQuestion">
<li>
<div class="short">
<label>Question 1</label>
<input />
<p class="description">Eg. This is a description.</p>
</div>
<%= Ajax.ActionLink("Text", "action", new { id = tId }, new AjaxOptions() { UpdateTargetId = "tItems" }, new { @class = "button" })%>
</li>
<li>
<div class="short">
<label>Question 2</label>
<input />
<p class="description">Eg. This is a description.</p>
</div>
<%= Ajax.ActionLink("Text", "action", new { id = tId }, new AjaxOptions() { UpdateTargetId = "tItems" }, new { @class = "button" })%>
</li>
</ul>
</div>
</div>
<div id="mask"></div>
</div>
喜歡你的想法$(」s tuff「,」#partialviewcounter「)。doSomething()...謝謝 – 2011-05-19 12:44:00