EasyUI SlideMenu(側邊菜單)組件綁定事件 添加事件 單擊事件

最近剛接觸了EasyUI框架,在看官方文檔的時候發現有些地方寫的不夠詳細。

官方SlideMenu的demo:

http://www.jeasyui.net/demo/959.html

在這裏插入圖片描述

官方SlideMenu文檔

http://www.jeasyui.net/plugins/754.html

在這裏插入圖片描述


官方對於事件的文檔只有寥寥一行,但是好在實踐出真知,在不斷嘗試下,找到了SlideMenu中標籤事件的方法綁定,話不多說看代碼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My Layout</title>
    <link rel="stylesheet" href="easyui/themes/gray/easyui.css" >
    <link rel="stylesheet" href="easyui/themes/icon.css">
    <script src="easyui/jquery.min.js"></script>
    <script src="easyui/jquery.easyui.min.js"></script>
    <style>
        html,body{margin:0;pading:0;}
    </style>
</head>
<body>

            <div id="sm" class="easyui-sidemenu" data-options="data:Data, onSelect:test" style="width: 100%"></div>

</body>
<script type="text/javascript">
    var Data = [{
        text: 'Item1',
        iconCls: 'icon-sum',
        state: 'open',
        children: [{
            text: 'Option1',
            click:'out'
        },{
            text: 'Option2'
        },{
            text: 'Option3',
            children: [{
                text: 'Option31'
            },{
                text: 'Option32'
            }]
        }]
    },{
        text: 'Item2',
        iconCls: 'icon-more',
        children: [{
            text: 'Option4'
        },{
            text: 'Option5'
        },{
            text: 'Option6'
        }]
    }];


    function test(item){
        alert(item.text);
        console.log(item.text);
    }

</script>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章