【问题标题】:JQuery popover keeps old variableJQuery popover 保留旧变量
【发布时间】:2016-01-13 22:25:51
【问题描述】:

I have a dropdown list that when selected sets a bunch of variables in C#.然后使用这些变量填充弹出框,然后用户单击 DDL 旁边的锚点。这很好,但事实上,当我更改 DDL 中的值时,弹出框会保留旧数据。它从不使用新数据更新/刷新。

总之,用户点击下拉菜单来更改变量。 DDL 旁边有一个帮助图标,用户单击该图标可显示弹出框,其中的数据是从 DDL 设置的变量中检索的。

我假设它在页面加载时第一次使用对象数据时保留。我尝试过多次销毁、隐藏和重写,它只是保留旧数据。

问题:如何让弹出框接受新数据。

$( document ).ready( function (){
$( "#ShowMeterInfo" ).popover( {
        title: '<h3 class="custom-title"><span class="glyphicon glyphicon-info-sign"></span>  Meter: <%=this.HiddenMeterName.Value%></h3>',
            content: "<p><ul><li><strong>Location:</strong><%=this.MeterLocation %></li><li><strong>Id:</strong> 321654</li><li><strong>Building:</strong><%=this.MeterBuilding%></li><li><strong>Site:</strong><%=this.MeterSite%></li></ul></p>",
            template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div><div class="popover-footer"><a href="#" class="btn btn-info btn-sm">Close</a></div></div>',
            html: true,
    animation: true
    } );

$( document ).on( "click", ".popover-footer .btn", function (){
        $( this ).parents( ".popover" ).popover( 'destroy' );
    } );                                               

});

除了数据不会刷新之外,它工作得很好!

【问题讨论】:

    标签: jquery html asp.net popover


    【解决方案1】:

    这是因为您使用的元素如下:,它将在 time.of 渲染时将该字段的值放入您的视图中。您需要获取对呈现的输入元素的引用并检索该值。

    因此,当显示弹出窗口时,请使用以下内容:

    $('#MeterLocation').val()
    

    这将获得该元素的当前值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 2012-10-29
      • 1970-01-01
      相关资源
      最近更新 更多