extjs4中Ext.Editor編輯控制項用法

來源:互聯網
上載者:User

1.用文字框編輯普通文本
下面通過一個編輯控制項作用在span標籤上,雙擊該標籤即可編輯該標籤的文本類容。

 代碼如下 複製代碼

[html]
    <h1>用文字框編輯普通文本</h1>
    <div class="content">
    <span id="span1">請雙擊我修改文字</span>
    </div>

[Js]
    //用文字框編輯普通文本
    var editor1 = new Ext.Editor({
        shadow: false,
        completeOnEnter: true,      //按斷行符號時自動完成
        cancelOnEsc: true,          //按ESC自動結束編輯
        updateEl: true,            //有變化時更新
        ignoreNoChange: true,       //不理會沒有變化的情況
        listeners: {
            complete: function (editor, value, oldValue) {
                Ext.Msg.alert('文本被改變', "從“" + oldValue + "” 變為“" + value + "”");
            }
        },
        field: {
            allowBlank: false,
            xtype: 'textfield',
            width: 150,
            selectOnFocus: true
        }
    });

    Ext.get("span1").on('dblclick', function (event, span1_dom) {
        editor1.startEdit(span1_dom);
    });

效果圖片如下

效果如下:

處於編輯狀態時:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.