Jquery jqmodal ajax 支持

发布于 2024-11-04 09:07:14 字数 2873 浏览 0 评论 0原文

我正在网站上使用模式,但我无法实现某些目标: 我使用的模式是 jqModal 在这里找到: http://dev.iceburg.net/jquery/jqModal/

我在初始化一个模式时没有任何问题。

<script type="text/javascript">$().ready(function() {
$('#cartdialog').jqm({ajax:'@href',trigger: 'a.jqModalcart'});
});</script>


<a class="jqModalcart" href="/ash/shop/cart2.php"><img src="/ash/images/viewcart.gif" 
alt="viewcart"/></a>

这将加载我的主模式,其中显示 cart2.php 的内容。

这就是问题所在,我知道可能有多种解决方案。 cart2.php 上有一个按钮,我希望用户单击该按钮并让模式从不同页面(shipping.php)加载新内容。最好将 cart2.php 替换为 Shipping.php,而不需要打开和关闭模态,或与当前模态重叠的嵌套模态。

让事情变得更加复杂的是,shipping.php 需要加载邮政编码,我为此编写了一个简单的 javascript 验证器。需要传递的链接看起来像这样:

href=("/ash/shop/shipping.php?zip=" + document.form9.zip.value)

我知道我可以通过像这样初始化它来将该链接获取到模态中:

<script type="text/javascript">$().ready(function() {
$('#idhere').jqm({ajax:'@href',trigger: 'a.classhere'});
});</script>

但是,我似乎无法从模态“触发”模态。

所以我有很多问题: 1)我可以保留一个模态并更改其中通过 AJAX 加载的内容(基本上是在一个模态窗口内的页面之间导航)吗?理想的解决方案!!! 2)如果没有...我如何创建一个嵌套模式,该模式将显示在主模式的顶部并加载上面的链接,该链接需要来自我的邮政编码验证器的信息(我可以提供ajax:'linkhere'),但我的链接有这部分添加到验证器“+ document.form9.zip.value”内的末尾 3)如果这是不可能的...我怎样才能使主模式上的按钮首先关闭主模式然后使用包含链接+zip的新内容加载辅助模式

我试图以最清晰的方式提供这一点把它从我的脑子里赶出去。我很乐意回答有关此问题的任何问题,因为我完全理解我可能还没有完全清楚

更多信息...我尝试过 .load() 但没有成功,但这很可能是因为我在这方面的技能很少。这是我的邮政编码脚本。我这样做是为了在输入 5 个字符后,链接会发生变化,以便用户首先看到“输入邮政编码”,然后看到“计算运费”,并且 href 也会发生变化。

<script language="javascript">

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}
</script>

<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length == limitNum) {
    limitField.value = limitField.value.substring(0, limitNum);

    //switch image out
    javascript:movepic('button','/ash/images/calculateshipping.gif');

    //change image link
    document.getElementById("tester").href=("/ash/shop/shipping.php?zip=" + document.form9.zip.value);
    document.getElementById("tester").onclick=function(){$('#cartdialog').load("/ash/shop/shipping.php?zip=" + document.form9.zip.value);};

} else {
    limitCount.value = limitNum - limitField.value.length;
}
}
</script>

我的 HTML 有一个表单...

<form id="form9" name="form9" method="post" action="">
<a id="tester" name="tester" class="jqModalship" href="#" style="margin-right:4px;"><img name="button" src="/ash/images/enterzipcode.gif" alt="Image"></a>
<input name="zip" type="text" size="5" onKeyDown="limitText(this.form.zip,this.form.countdown,5);" 
onKeyUp="limitText(this.form.zip,this.form.countdown,5);" maxlength="5">
</form>

为什么我无法使用上面的方法将新页面加载到模式中?

I am making use of a modal on a site, and I am having trouble achieving something:
The modal I am using is jqModal found here: http://dev.iceburg.net/jquery/jqModal/

I have no issue initializing one modal.

<script type="text/javascript">$().ready(function() {
$('#cartdialog').jqm({ajax:'@href',trigger: 'a.jqModalcart'});
});</script>


<a class="jqModalcart" href="/ash/shop/cart2.php"><img src="/ash/images/viewcart.gif" 
alt="viewcart"/></a>

This will load up my main modal which displays the contents of cart2.php.

Here is the problem and I know there may be multiple solutions. cart2.php has a button on it, that I want the user to click and have the modal load new content from a different page (shipping.php). Preferably, it would swap out cart2.php for shipping.php, without the need of opening and closing modals, or nested modals that overlap the current one.

Further complicating the matter, shipping.php needs to be loaded with a zip code, which I have written a simple javascript validator for. The link that needs to be passed on looks like this:

href=("/ash/shop/shipping.php?zip=" + document.form9.zip.value)

I know I can get that link into the modal by initializing it like this:

<script type="text/javascript">$().ready(function() {
$('#idhere').jqm({ajax:'@href',trigger: 'a.classhere'});
});</script>

However, I cant seem to "trigger" a modal from a modal.

So I have many questions:
1)Can I leave one modal and change what is being loaded via AJAX inside of it (basically navigate to and from pages within one modal window)? IDEAL SOLUTION!!!!
2)If not...how can I create a nested modal that will show over top of the main modal AND load the link above which requires information from my zip code validator (I can give ajax:'linkhere') but my link has this part added to the end of it within the validator "+ document.form9.zip.value"
3)If that isnt possible...how can I make the button on the main modal FIRST close the main modal THEN load the secondary modal with the new content CONTAINING the link + zip

I have tried to provide this in the clearest way I can get it out of my brain. I will be happy to answer any questions about this as I completely understand I may have not been entirely clear

More info...I have tried .load() with no success but it is most likely because I have very little skill in this area. Here is my zip code script. I have it so that after 5 characters are entered, the link changes so that the user first sees"enter zip code" but then sees "calculate shipping" and the href changes as well.

<script language="javascript">

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}
</script>

<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length == limitNum) {
    limitField.value = limitField.value.substring(0, limitNum);

    //switch image out
    javascript:movepic('button','/ash/images/calculateshipping.gif');

    //change image link
    document.getElementById("tester").href=("/ash/shop/shipping.php?zip=" + document.form9.zip.value);
    document.getElementById("tester").onclick=function(){$('#cartdialog').load("/ash/shop/shipping.php?zip=" + document.form9.zip.value);};

} else {
    limitCount.value = limitNum - limitField.value.length;
}
}
</script>

My HTML has a form...

<form id="form9" name="form9" method="post" action="">
<a id="tester" name="tester" class="jqModalship" href="#" style="margin-right:4px;"><img name="button" src="/ash/images/enterzipcode.gif" alt="Image"></a>
<input name="zip" type="text" size="5" onKeyDown="limitText(this.form.zip,this.form.countdown,5);" 
onKeyUp="limitText(this.form.zip,this.form.countdown,5);" maxlength="5">
</form>

Why can I not load the new page into the modal using the above?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈下烟灰 2024-11-11 09:07:14

要更改模态框的内容,您可以使用 .load() 来更新模态框的 div。

或者,您可以使用 iframe 功能(请参阅 http://dev.iceburg.net/jquery/ 中的#7 jqModal/)。这将允许您提到的“在模态内部导航”。

第二个选项可能需要加载第二个模态的侦听器,因为我不确定 jqModal 是否允许延迟加载(在初始化后处理注入到 DOM 的代码...如 .live())。

第三个选项是黑客祈祷版本。它会起作用,但你不想使用这个。

To change the content of the modal, you could use a .load() to update the modal's div.

Alternatively you can use the iframe capabilities (see #7 at http://dev.iceburg.net/jquery/jqModal/). This would allow the 'navigating inside the modal' you mentioned.

The second option would probably need to load the second modal's listener along with it, as i'm not sure jqModal allows lazy loading (working on code injected into the DOM after initializing... like .live())

The third option is a hack-n-pray verion. It'll work, but you don't want to use this one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文