在IE8和IE7上调用.dialog()时出错

时间:2013-01-28 09:06:18

标签: jquery jquery-ui

我在IE8&上收到错误消息调用.dialog()时的IE7。

我从IE控制台收到的错误消息是:

  

SCRIPT438:Object不支持此属性或方法。

     

jquery-1.7.2.min.js,第2行字符21784

这是我的代码:

// Add to cart button clicked
$tablePanel.on('click', '.AddToCartButton', function (e) {
    $('#mdlPopup_backgroundElement').show();


var optionId = +e.target.getAttribute('optionid');       
var categoryId = +e.target.getAttribute('categoryid');       
// Get the product shoptCityId from previous <tr>       
var $baseProdTr = $(e.target).closest('td.info_row').parent().prev();       
var shopCityId = +$baseProdTr.attr('shopcityid');


// For Dev!
if (isNaN(shopCityId)) {        
    alert('Error:\nFailed to get the shopCityId value from the base product <tr>');
    return;           
}

// Close the product <tr> in the table
oTable.fnClose($baseProdTr[0]);

var shopDisplay = $baseProdTr.find('b.shopDisplay').text();

$.post(urlAddToCart, { productOptionId: optionId, shopCityId: shopCityId, shopDisplay: shopDisplay, categoryId: categoryId }, function (result) {

    if (result === 'EmptyView') {
        updateCartItemsCount();

        $('#mdlPopup_backgroundElement').hide();
        return;
    }

    var $input = $(result).filter('#hdnModalProps');           
    var className = $input.attr('classval');           
    var width = $input.attr('widthval');         
    var height = $input.attr('heightval');

    // --------- the error occurred here:  ------------------
        $modalDialog = $(result).dialog({ modal: true, draggable: false, resizable: false, width: width,
            dialogClass: className + 'noTitleDialog'
        });


    $('#mdlPopup_backgroundElement').hide();

});

});

我正在使用:jquery-ui-1.8.11.min.js

你可以在这里看到这个:

http://2send.co.il/Products/%D7%A2%D7%A4%D7%95%D7%9C%D7%94/%D7%A2%D7%A6%D7%99%D7%A6%D7%99%D7%9D

  1. 点击照片。
  2. 点击粉红色按钮
  3. 感谢。

2 个答案:

答案 0 :(得分:2)

对话方法来自jQuery UI library

您不仅应该在代码中包含jQuery,还应该包含jQuery UI库。 如果您已经完成了,请显示完整的代码。

答案 1 :(得分:0)

对话框内容来自服务器\ r \ n,IE8不解析那些\ r \ n和制作DOM元素。所以在js中,我添加了代码来从内容中删除\ r \ n。

  

result = result.replace(/ \ r \ n / g,'')。renplace(/ \ s + / g,'');

     

$ modalDialog = $(result).dialog({modal:true,draggable:false,resizable:false,width:width,height:height,                   dialogClass:className +'noTitleDialog'               });