Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json qtip插件没有';不能使用jquery jtemplates插件_Json_Jquery_Qtip_Jtemplates - Fatal编程技术网

Json qtip插件没有';不能使用jquery jtemplates插件

Json qtip插件没有';不能使用jquery jtemplates插件,json,jquery,qtip,jtemplates,Json,Jquery,Qtip,Jtemplates,我正在使用Ajax加载数据 在jQuery jTemplates的帮助下,我在容器中加载数据。我需要将jqtip插件应用于带有容器的图像,但由于某些原因,它不起作用。如果它在外面工作的话 知道它为什么不起作用吗?也许能告诉我如何调试它 这是我的密码 $.ajax({ type: "POST", url: "/json/default.aspx/loaditems", data: "{'parameter':'" + parameter + "'}"

我正在使用Ajax加载数据

在jQuery jTemplates的帮助下,我在容器中加载数据。我需要将jqtip插件应用于带有容器的图像,但由于某些原因,它不起作用。如果它在外面工作的话

知道它为什么不起作用吗?也许能告诉我如何调试它

这是我的密码

$.ajax({
        type: "POST",
        url: "/json/default.aspx/loaditems",
        data: "{'parameter':'" + parameter + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {                
            ApplyTemplate(msg);    
        }
    });

function ApplyTemplate(msg) {

    $('#Container').setTemplateURL('/scripts/template.htm', null, { filter_data: true });
    $('#Container').processTemplate(msg);

}

<div id="Container">
</div>
$.ajax({
类型:“POST”,
url:“/json/default.aspx/loaditems”,
数据:“{'parameter':'”+parameter+“}”,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:函数(msg){
应用模板(msg);
}
});
函数ApplyTemplate(msg){
$('#Container').setTemplateURL('/scripts/template.htm',null,{filter_data:true});
$('#Container').processTemplate(msg);
}
这是my template.htm页面的内容

{#foreach $T.d as post}
        <div class="image_wrap" style="float: left;">
            <a href="{$T.post.url}">
                <img width="175" src="{$T.post.profimage}" title="test" /></a>
        </div>
        {#/for}
{#foreach$T.d as post}
{#/for}
这是qtip代码

<script type="text/javascript">
        $(function () {


            $('.image_wrap img[title]').qtip({
                position: {
                    corner: {
                        target: 'topMiddle',
                        tooltip: 'bottomMiddle'
                    }
                },
                style: {
                    name: 'cream',
                    padding: '7px 13px',
                    color: '#350608',
                    width: {
                        max: 250,
                        min: 0
                    },
                    tip: true
                }
            });
        });
    </script>

$(函数(){
$('.image_wrap img[title]').qtip({
职位:{
角落:{
目标:'topMiddle',
工具提示:“底部中间”
}
},
风格:{
名字:'奶油',
填充:“7px 13px”,
颜色:“#350608”,
宽度:{
最高:250,
最低:0
},
提示:没错
}
});
});

您正在$(document).ready()上运行qtip逻辑。问题在于,由于您在加载页面后加载新标记,因此qtip逻辑不适用于该页面

尝试将qtip逻辑包装到函数中,然后在运行AJAX调用后调用该函数

大概是这样的:

function InitQtip() {
     $('.image_wrap img[title]').qtip({
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            name: 'cream',
            padding: '7px 13px',
            color: '#350608',
            width: {
                max: 250,
                min: 0
            },
            tip: true
        }
    });
}

// This will take care of items loaded with the page.
$(function () {
    InitQtip();
}

// This will take care of new items.
$.ajax({
    type: "POST",
    url: "/json/default.aspx/loaditems",
    data: "{'parameter':'" + parameter + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {                
        ApplyTemplate(msg);
        InitQtip();
    }
});

您正在$(document).ready()上运行qtip逻辑。问题在于,由于您在加载页面后加载新标记,因此qtip逻辑不适用于该页面

尝试将qtip逻辑包装到函数中,然后在运行AJAX调用后调用该函数

大概是这样的:

function InitQtip() {
     $('.image_wrap img[title]').qtip({
        position: {
            corner: {
                target: 'topMiddle',
                tooltip: 'bottomMiddle'
            }
        },
        style: {
            name: 'cream',
            padding: '7px 13px',
            color: '#350608',
            width: {
                max: 250,
                min: 0
            },
            tip: true
        }
    });
}

// This will take care of items loaded with the page.
$(function () {
    InitQtip();
}

// This will take care of new items.
$.ajax({
    type: "POST",
    url: "/json/default.aspx/loaditems",
    data: "{'parameter':'" + parameter + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {                
        ApplyTemplate(msg);
        InitQtip();
    }
});