模态:在document.load()之后通过AJAX加载的元素中使用模态(Modal: using modal within elements that were loaded via AJAX a

编程入门 行业动态 更新时间:2024-10-22 11:42:19
模态:在document.load()之后通过AJAX加载的元素中使用模态(Modal: using modal within elements that were loaded via AJAX after document.load())

发生了什么:我有一个页面,用户必须单击一个按钮,选择以模态显示。 当他们点击他们想要的页面上的div元素时,通过AJAX更新,它显示了他们选择的内容,并有一个选项“查看项目”。

我已经定义了“视图项”应该打开另一个模态视图,它将包含项目的所有信息,现在,参考上面的段落,而不是打开模态视图用户正在转移到该页面?

问题:是否可以在文档加载阶段后加载的元素上激活模态?

示例代码:在初始加载时,用户会看到以下代码,在此示例中,项目在加载之前设置:

<div id="dynamic-area"> Item 1 <a href="selection/view/1" data-tip="tooltip" data-placement="top" data-original-title="View" data-toggle="modal">view selection</a> </div> <input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection

当用户在单击“更改选择”后选择了不同的项目时,#dynamic-area已使用通过AJAX在所选项目上获取的数据进行了全面更新。

所以,假设用户选择了第3项,我们将在下面输入代码:

<div id="dynamic-area"> Item 3 <a href="selection/view/3" data-tip="tooltip" data-placement="top" data-original-title="View" data-toggle="modal">view selection</a> </div> <input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection

现在,如果用户点击“视图选择”,当用户看到模态时,用户正在进入页面'selection / view / 3'。

What happened: I have a page where user has to click on a button and selection is displayed in modal. When they clicked on what ever they wanted div element on the page is updated, via AJAX, which shows what they have selected and has an option "view item".

I have defined that "view item" should open up another modal view which will have all the information on the item, and now, referring to the above paragraph, rather then opening modal view user is being transferred to that page?

Question: Is their a walk around for modal to be activated on the elements that were loaded after document load stage?

Example code: On initial load user is presented with following code, at this example item was set prior to load:

<div id="dynamic-area"> Item 1 <a href="selection/view/1" data-tip="tooltip" data-placement="top" data-original-title="View" data-toggle="modal">view selection</a> </div> <input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection

When user have picked a different item after clicking on "change selection" #dynamic-area was fully updated with a data that was fetched via AJAX on the selected item.

So lets say, if user have picked item 3, we would have code below:

<div id="dynamic-area"> Item 3 <a href="selection/view/3" data-tip="tooltip" data-placement="top" data-original-title="View" data-toggle="modal">view selection</a> </div> <input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection

Now if user to click on the "view selection", user is being to the page 'selection/view/3' when user should see modal.

最满意答案

在扩展此功能后,操作按预期工作

After extending this function action worked as it should

更多推荐

本文发布于:2023-07-06 07:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047353.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模态   元素   加载   load   document

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!