easyui解析器parser,easyui解析parser

來源:互聯網
上載者:User

easyui解析器parser,easyui解析parser

在寫代碼的時候發現如果不是一次在頁面寫好html代碼,而是通過頁面載入完成後執行某個方法時添加相應的組件時,添加上去後easyui是不會給你初始化這個組件的,這個時候就必須手動的去初始化這個組件,

如我下面寫的聊天視窗,點擊聊天的時候初始化視窗,這個時候就需要用到

$.parser.parse('#cc');  // 解析指定節點

才能初始化視窗,否則追加上去是沒有效果的,但是發現用是時候這個id又不能為當前組件的id,必須為當前組件的父容器的id

如:<div id="customerChatWindow" class="easyui-window"></div>

這是easyui的window組件,這個 id不能在parser中用,否則沒效果,必須給其添加一個父容器使用父容器的id

<div id="showChatwindow">

    <div id="customerChatWindow" class="easyui-window"></div>

</div>

$.parser.parse('#showChatwindow');

這麼使用才會正常


function initChatsWindow(oid){

    
    var chat = '<div id="showChatwindow">';
    chat += '<div id="customerChatWindow" class="easyui-window" data-options="title:\'聊天\',width:400,height:600,';
    chat += 'collapsible:false,minimizable:false,maximizable:false,onResize:function(width, height){$(\'#messageDataview\').height(height-38-145);}">';
    chat += '<input id="customerId" type="hidden" />';
    chat += '<div id="chartWindow" class="easyui-layout" style="width:100%;height:100%;" data-options="fit:true">  ';
    chat += '    <div data-options="region:\'center\',noheader:true">';
    chat += '        <div style="border-width: 0px; overflow: auto; margin: 0px; width: 100%; height: 415px; left: 0px; top: 0px; background-color: white;"';
    chat += '            id="messageDataview" >';
    chat += '        </div>';
    chat += '        <div id="panel-1219" style="margin: 0px; width: 100%; left: 0px; bottom: 0px; position: absolute;background-color: #d3e1f1;overflow: hidden;">';
    chat += '            <div id="toolbar-1221" style="width: 100%; left: 0px; top: 0px;height: 22px;">';
    chat += '                <table style="width:100%">';
    chat += '                    <tr>';
    chat += '                        <td width="50%">';
    chat += '                                <div id="container-1222" style="margin: 0px; left: 0px; top: 0px;">';
    chat += '                                <img id="filefield-1223-buttonEl-btnIconEl" onclick="sendImageToUserOfChat($(\'#customerId\').val());" src="/oss-portlet/images/icons/btn_send_pic.png" />';
    chat += '                            </div>';
    chat += '                        </td>';
    chat += '                        <td width="50%" align="right">';
    chat += '                            <div style="border-width: 1px;">';
    chat += '                                <a href="javascript:void(0)" onclick="openOrCloseChatsMessageHistoryInfo($(\'#customerId\').val());" style="width:80px">';
    chat += '                                    <img src="/oss-portlet/images/icons/btn_history.png" />';
    chat += '                                    <span id="button-1225-btnInnerEl" class="x-btn-inner">曆史訊息</span>';
    chat += '                                </a>';
    chat += '                            </div>';
    chat += '                        </td>';
    chat += '                    </tr>';
    chat += '                </table>';
    chat += '            </div>';
    chat += '            <div id="panel-1219-body" style="width: 100%; left: 0px; top: 26px; height: 95px;overflow: hidden;">';
    chat += '                <table style="border-width: 0px; table-layout: fixed; margin: 0px; width: 100%;" id="textareafield-1220">';
    chat += '                    <tbody>';
    chat += '                        <tr id="textareafield-1220-inputRow">';
    chat += '                            <td id="textareafield-1220-bodyEl" colspan="3" style="width: 100%;">';
    chat += '                                <textarea id="chatcontent" name="textareafield-1220-inputEl" rows="4" cols="20"';
    chat += '                                    style="width: 96%;overflow: auto;"></textarea>';
    chat += '                            </td>';
    chat += '                        </tr>';
    chat += '                    </tbody>';
    chat += '                </table>';
    chat += '            </div>';
    chat += '            <div style="width: 100%; left: 0px; top: 90px;background-color: #d3e1f1;">';
    chat += '                <p align="right" style="margin:0;">';
    chat += '                    <a class="easyui-linkbutton" href="javascript:void(0)" onclick="sendChatsMessage($(\'#customerId\').val(), $(\'#chatcontent\').val());" style="width:80px">發送(Enter)</a>';
    chat += '                </p>';
    chat += '            </div>';
    chat += '        </div>';
    chat += '    </div>';
    chat += '</div>';
    chat += '</div>';
    chat += '</div>';
    
    // 添加到body中
    $("body").append(chat);
    // 解析當前組件,id必須為該組件的父節點
    $.parser.parse('#showChatwindow');
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.