gpt4 book ai didi

jquery - 渲染部分 View 时 jquery 的 $(document).ready() 如何 react ?

转载 作者:行者123 更新时间:2023-12-01 01:10:42 24 4
gpt4 key购买 nike

在 $(document).ready() 中,我正在生成一个模型弹出窗口以在页面上添加项目,并且当页面第一次加载时它工作正常,但如果出现以下情况,它不会再次显示模式弹出窗口它至少被调用一次,所以请告诉我我哪里做错了,它没有显示模态视图?

或者

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>

最佳答案

$(文档).ready(function () {

当页面准备好时,将调用就绪语句内的任何 block 。如果页面已经存在,则会立即调用它

关于jquery - 渲染部分 View 时 jquery 的 $(document).ready() 如何 react ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6058232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com