qTip和动态添加元素的问题

1110

我有一个页面,UpdatePanel该页面上单击可以添加一些表单。
在那些新添加的元素中,我必须使用图像qTip

我有这个:

$(document).ready(function () {    
        $('.ttip').qtip({
            content: $(this).attr('tooltip'),
            show: 'click',
            hide: 'click',
            position: {
                my: 'top right',
                at: 'bottom center'
            },
            style: { classes: 'ui-tooltip-light' }
        });
    });

这适用于一开始就可见的元素。
所有使用的元素qTip都具有runat="server"属性。
但是,当我用类添加新元素时,ttip它不起作用。

进行检查,我发现在开始时可见的元素具有属性:

data-hasqtip="6"

但是动态添加的元素没有此属性。

我该如何解决?
如何使这种生活成为现实?

基于答案的更新

我已在使元素可见的代码中添加了此代码:

// Button click handler that add new element to page
public void AddNewElement(Image image)
{
    image.Visible = true;
    image.ToolTip = "blah";
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(),
                        "tmp",
                        @"<script type='text/javascript'>
                            $('.ttip').filter(function(){return !$(this).data('qtip')}).qtip(
                                content: $(this).attr('tooltip'),
                                show: 'click',
                                hide: 'click',
                                position: {
                                    my: 'top right',
                                    at: 'bottom center'
                                },
                                style: { classes: 'ui-tooltip-light' }
                            );
                        </script>", 
                        false);
}

但这仍然行不通:(

沃尔夫

添加新元素后,重新初始化qTip插件:

$('.ttip').filter(function(){return !$(this).data('qtip')}).qtip(...);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章