【问题标题】:Show popover via Ajax call通过 Ajax 调用显示弹出框
【发布时间】:2013-09-24 08:46:12
【问题描述】:

我试图在图像悬停时显示弹出框,弹出框的内容是对模板的 Ajax 调用的响应。在此模板中,我有标签(在 taglib 中使用),其中呈现了我的弹出框模板.在我的回复中,我可以获得我的弹出内容,但它不会显示在图像的悬停上。

编辑: 这是我在模板中使用的标签:

<cv:advice resumeSection="Additional" fieldId="int" resume="${resume}"/>

以及使用标签的taglib:

def advice = { attrs, body ->
    Resume resume = attrs.resume
    String resumeSection = attrs.resumeSection
    String fieldId = attrs.fieldId
    AdviceBox adviceBox =   AdviceBox.findByResumeSectionAndFieldIdAndResumeType(resumeSection, fieldId,   ResumeType.findById(1))
    if (adviceBox) {
        out << g.render(template: "../templates/popover", model: [adviceBox: adviceBox, resumeSection: resumeSection, fieldId: fieldId])
    }
}

弹出框模板代码为:

<a href="#" class="popover-with-html" rel="popover" data-html="true"    data-trigger="hover" title="${adviceBox?.title}" data-content="${adviceBox?.content}">
<img onclick="adviceEvent('${resumeSection}', '${fieldId}');" src="${g.resource(dir:  'images/CvSurgeonLegacy', file: 'question_mark.gif')}"/>
</a>

【问题讨论】:

  • 请看我编辑的问题。
  • 您确定您的数据是 html 格式的吗?
  • 是的,当然........我已经通过 alert() 进行了检查
  • 请发布您的html代码。
  • 这是生成的 html:

标签: jquery ajax twitter-bootstrap grails popover


【解决方案1】:

请使用

$('.popover-with-html').popover(); 

在 ajax 响应之后。它应该可以工作。

参考:popovers

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多