0

このエラーはローカルで発生しています。特定のDOMを追加すると発生します。

TypeError: string is undefined  

return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );

jquery.js (line 622)

本番環境には表示されませんが、ローカルで時々発生します。私はそれをデバッグしましたが、何も見つかりませんでした。jquery 1.8.2を使用しています。

他の誰かがこれに遭遇したことを期待して、ここに投稿します。(私は解決策を期待していません)

これを引き起こすコードは次のとおりです。

flash = function(type, message, secondaryMessage) {
    var flash_location = $('.flash-location');
    var secondary = '';
    type = type || 'error';
    message = message || (type == 'success' ? 'Success' : 'Error');
    if(secondaryMessage){
        secondary = '<p class="secondary">'+secondaryMessage+'</p>';
    }
    var top = 5;
    flash_location.append($('<div class="flash"><div class="flash-content ' + type + '" style="top:'+top+'px;"><table><tr><td class="flash-icon"></td><td><p class="primary">' + message + '</p>'+secondary+'</td></tr></table></div></div>').fadeIn('normal'));
};
4

1 に答える 1

0

appendDOM を使用して要素を作成しても問題は発生しますか?

flash = function(type, message, secondaryMessage) {
    var flash_location = $('.flash-location'),
        top = 5,
        table = $('<table />'),
        tr = $('<tr />'),
        td = $('<td />'),
        p = $('<p />'),
        div = $('<div />'),
        td1 = td.clone().addClass('flash-icon'),
        td2 = td.clone().append(p.clone().addClass('primary')),
        flashContent = div.clone().addClass('flash-content').addClass(type).css('top', top + 'px'),
        flash = div.clone().addClass('flash');
    type = type || 'error';
    message = message || (type == 'success' ? 'Success' : 'Error');
    if(secondaryMessage){
        td2.append(p.clone().addClass('secondary').text(secondaryMessage));
    }
    tr.append(td1).append(td2);
    table.append(tr);
    flashContent.append(table);
    flash.append(flashContent);
    flash_location.append(flash).fadeIn('normal'));
};
于 2012-11-19T13:34:36.480 に答える