jQuery .ajax成功函数未使用jQuery UI元素呈现html [英] jQuery .ajax success function not rendering html with jQuery UI elements

查看:102
本文介绍了jQuery .ajax成功函数未使用jQuery UI元素呈现html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jquery将.ajax渲染中的html加载到div中?成功函数将加载HTML,但这些元素不会显示为jQuery UI元素,而只会显示为静态HTML类型.有指针吗?

How do I have the html loaded into my div from the .ajax render with jquery? the success function loads the HTML, but those elements do not show up as jQuery UI elements, just the static HTML types. Any pointers?

$(function() {
$('input[type=image]').click(function(){
    $.ajax({
        url: '_includes/callinfo.php',
        data: 'id=' + $(this).attr('value'),
        dataType: "html",
        success: function(html){
            $('#callwindow').html(html); 
        }
    });
});

});

推荐答案

我需要做的是首先将数据(html)放入指定的div中,然后为html中的每个元素初始化插件.像这样:

What I needed to do was first bring in the data (html) into the specified div, then initialize the plugin for each of the elements inside the html. Like So:

$(function() {
$('input[type=image]').click(function(){
    $.ajax({
        url: '_includes/callinfo.php',
        data: 'id=' + $(this).attr('value'),
        dataType: "html",
        success: function(html){
            $('#callwindow').html(html);
                             // Initialize UI Items
            $("input:submit", ".callsubmit").button();
            $("#hotorcold").buttonset();
            $("#calldatep").datepicker();
            $("#callbackdatep").datepicker();   
        }

    });

});

});

这篇关于jQuery .ajax成功函数未使用jQuery UI元素呈现html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆