Jquery对话框IE9内容未使用html显示

Jquery dialog IE9 content not showing using html

本文关键字:未使用 html 显示 对话框 IE9 Jquery      更新时间:2023-09-26

我没有一个小型的客户端web应用程序。我已经在firefox、chrome、IE7、IE8和IE9中进行了测试。

现在我不能让它失败。它适用于我测试过的每一个浏览器/版本。我不确定我的客户使用的是什么版本,但他说是IE9。

代码是这样的:

function noticeBox(type, html, title) {
switch(type) {
    case 1:
    $('#notice_box').dialog({
        title: title,
        width: 400,
        modal: true,
        position: 'center',
        buttons: {
            'Ok': function() {
                $(this).dialog('close');
            }
        }
    });     
    break;
    case 2:
    $('#notice_box').dialog({
        title: title,
        width: 800,
        modal: true,
        position: 'center',
        buttons: {
            'Bekræft og bestil': function() {
                $('#form_products').submit();
            },
            'Annuller': function() {
                $(this).dialog('close');
            }
        }
    });     
    break;
    case 3:
    $('#notice_box').dialog({
        title: title,
        width: 400,
        modal: true,
        position: 'center',
        buttons: {
            'Luk': function() {
                $(this).dialog('close');
            }
        }   
    });
    break;
}
alert(html);
$('#notice_box').html(html);
$('#notice_box').dialog('open'); }

不是一个非常通用的函数,但这正是目前失败的地方。他说,当对话框弹出时,对话框中没有任何内容。他可以看到按钮,但就像对话框中没有html一样。

有什么想法吗?

更新:顺便说一句,他可以激活几个对话框,所有对话框的结果都是一样的。没有任何内容的对话框。

更新2:我如何使用该函数的一个例子是这样的。当客户订购某些产品时:

function order() {
var procuct_str = '';
var found_order = false;
$.each($('.order_input'), function(){
    var product_id = $(this).attr('id').split('-');
    if(parseInt($(this).val()) > 0) {
        found_order = true;
        procuct_str = procuct_str+'<div class="float_left"><span class="bread_text">'+$('#description-'+product_id[1]).text()+'</span></div><div class="float_right"><span class="bread_text">'+$(this).val()+'</span></div><div class="clear"></div>';
    }
}); 
if(found_order == true) {
    procuct_str = '<div class="float_left"><b>Beskrivelse</b></div><div class="float_right"><b>Antal kasser</b></div><div class="clear"></div>'+procuct_str;
    noticeBox(2, procuct_str, 'Bekræftelse');
    var found_order = false;
} }

除非您在其他地方声明了html变量,否则需要在函数的范围内访问它。根据您提供的代码,html是一个函数参数,在函数之外,它总是"未定义"的。

它对我来说很好。

我用你的函数是这样的:

noticeBox(1, "<p>Hello</p>", "Test");

您的客户端为html参数提供了什么?一些html可能会把它搞砸。或者只是你的客户遗漏了它,这可以解释为什么什么都没有显示。