jquery ui - 模式对话框(创建模式内容的更好方法?)
有没有办法在 JavaScript 中定义模式内容,而不是总是必须在页面上有一个元素并从中创建对话框?
它有标题选项,因此我可以“动态”创建模态标题,但实际内容呢?就像说我需要它说,“你要删除图像#539”。而不是为每个可能的图像创建一个模式 - 或者甚至创建元素然后从中创建对话框。
一定有更好的方法。
Is there a way to define the modal content in the javascript, rather than always having to have an element on the page and create the dialog from that?
It has the title option, so I can 'dynamically' create a modal title, but what about the actual content? Like say I need it to say, "you are going to delete image #539". Rather than creating a modal for every possible image - or even from creating the element and then making the dialog from that.
There's got to be a better way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试以下内容:
HTML
Javascript
演示此处< /a>.
You could try something like this:
HTML
Javascript
Demo here.
这是另一个更动态的解决方案:
然后,当您需要调用错误模式时,只需执行以下操作:
您可以想象向函数添加更多参数来控制宽度、高度等。
享受吧!
Here's another solution, a bit more dynamic:
Then when you need to call the error modal simply do:
You can imagine adding more parameters to the function to control the width, height, etc.
Enjoy!
谢谢斯科特。我为对话框添加了一个标题属性:
...
...
演示
Thank you Scott. I have added a title attribute for the dialog:
...
...
Demo