提交页面后维护弹窗

发布于 2024-10-31 19:31:55 字数 232 浏览 1 评论 0原文

我的客户正在使用 Magento,单击提交按钮后,表单提交到控制器,然后提交到同一页面重新加载。他问我的是,一旦他点击提交按钮,他希望显示一个弹出窗口。所以我以动态方式(JavaScript)使用了一个禁用背景的div作为弹出窗口,但是由于按钮是“提交”,页面刷新并且我丢失了弹出窗口,所以即使在提交后也可以保持该div的显示?

My client is using Magento, and after clicking the submit button, the form submits to the controller and then the same page reloads. What he asked me is once he clicks on the submit button he wants a popup displayed. So I used a div with a disabled background as a popup in a dynamic way (JavaScript), but since the button is "submitting", the page refreshes and I lose the popup, so is it possible to keep that div displayed even after submitting?

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

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

发布评论

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

评论(4

筑梦 2024-11-07 19:31:55

Jquery 示例:

$(document).ready(function(){
    $('#form_selector').submit(function(){
        showDialog();
        //stop submit
        return false;
    });
    $('#dialog_button_selector').click(function(){
        //submit form
        $('#form_selector').submit();
    });
});

Jquery example:

$(document).ready(function(){
    $('#form_selector').submit(function(){
        showDialog();
        //stop submit
        return false;
    });
    $('#dialog_button_selector').click(function(){
        //submit form
        $('#form_selector').submit();
    });
});
栖竹 2024-11-07 19:31:55

我不熟悉万磁王,但一般来说,当页面重新加载并调用弹出窗口时,您不能在控制器中查找表单提交吗?如果是的话?

I'm not familiar with Magneto, but generally speaking, couldn't you look for a form submit in the controller when the page reloads and call for the popup, if true?

物价感观 2024-11-07 19:31:55

为什么不使用滑动面板而不是弹出面板?

例如,检查 Magento 的 isLoggedin 功能:

<?php
if ($this->helper('customer')->isLoggedIn() ) {
    echo "Welcome!";
} else {
    echo "Please log in.";
}
?>

如果客户已登录,则在滑动面板内显示客户的必要信息。

如果您只想显示一次此面板,请尝试使用 magento 的事件观察器方法:

app/code/core/Mage/Customer/Model/Session.php

事件名称:

  • customer_login
  • customer_session_init

对于 jQuery 滑动面板,您可以使用支持的 jqEasy showOnLoad 属性。

jqEasy

Why don't you use slide panel instead of pop-up panel?

For instance, check isLoggedin function of Magento :

<?php
if ($this->helper('customer')->isLoggedIn() ) {
    echo "Welcome!";
} else {
    echo "Please log in.";
}
?>

if customer is logged, show necessary information of customer inside the slide panel.

If you want just one time show this panel, try to event observer methods of magento :

app/code/core/Mage/Customer/Model/Session.php

Event names :

  • customer_login
  • customer_session_init

For jQuery Sliding Panel, you can use jqEasy which is supporting showOnLoad property.

jqEasy

夜司空 2024-11-07 19:31:55

鉴于您不想保留页面的提交,您基本上需要在页面提交后回显弹出窗口。因此,使用一些通用事件(catalog_product_add_to_cart_after),添加一个会话变量,如下所示:

public function observer($event) {
    Mage::getSingleton("customer/session")->setNeedsCartPopup(true);
}

然后,在模板中,您可以检查此变量是否存在以显示弹出窗口:

$session = Mage::getSingleton("customer/session");
if($session->getNeedsCartPopup()) {
    $session->->setNeedsCartPopup(false);
    // echo HTML to display popup as the page loads
}

这不是经过测试的代码,但它应该为您提供如何捕获事件并在模板中响应它的要点。希望有帮助!

谢谢,

Given that you don't want to hold submission of the page, you basically need to echo the popup after the page is submitted. So, using some generic event (catalog_product_add_to_cart_after), add a session variable like this:

public function observer($event) {
    Mage::getSingleton("customer/session")->setNeedsCartPopup(true);
}

Then, in your template, you can check for the existence of this variable to show your popup:

$session = Mage::getSingleton("customer/session");
if($session->getNeedsCartPopup()) {
    $session->->setNeedsCartPopup(false);
    // echo HTML to display popup as the page loads
}

This is not tested code, but it should give you the gist of how to capture the event and respond to it in the template. Hope that helps!

Thanks,
Joe

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