在刷新打开模态 [英] On refresh open modal

查看:87
本文介绍了在刷新打开模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用API​​获取股票价格并通过模式显示。现在我做的是添加一个获取当前价格的按钮:

I am using an API to get a ticker price and its being displayed through a modal. Now what I did was add a button that says "Get Current Prices":

<button onClick="window.location.reload()" type="button" class="btn btn-default">Get Current Prices</button>

当你点击它成功刷新页面但我希望它再次打开模态。我确实在堆栈溢出上找到了一些东西,在页面加载时它会打开一个模态。它几乎可以工作但我只想在点击获取当前价格按钮时打开它。

When you click it refreshes the page successfully but I want it to open the modal again. I did find something on stack overflow where on page load it opens a modal. It almost works but I only want it to open if the "Get Current Prices" button has been clicked.

链接到另一个SO问题:在页面加载时启动Bootstrap模式

Link to the other SO question: Launch Bootstrap Modal on page load

推荐答案

建议您使用ajax调用刷新页面,而不是重新加载整个页面以刷新代码。

Would suggest you refresh your page using an ajax call rather than reloading the entire page to refresh a ticker.

如果你真的需要重新加载页面然后传递一个你可以检查的url param。

If you really need to reload the page then pass a url param which you can check for.

你可能不得不使用window.location.href =MyUrl?openModal = true

You'll probably have to use window.location.href = "MyUrl?openModal=true"

您可以在window.onLoad事件中检查此值,并根据此值打开模态对话框。

You can check for this value in the window.onLoad event and open your modal dialog based on this value.

这篇关于在刷新打开模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆