ホームページ  >  記事  >  ウェブフロントエンド  >  jquery.simple.tree プラグイン よりシンプルで互換性の高い無限ツリー plug-in_jquery

jquery.simple.tree プラグイン よりシンプルで互換性の高い無限ツリー plug-in_jquery

WBOY
WBOYオリジナル
2016-05-16 18:20:291099ブラウズ

効果は次のとおりです:

選択:
jquery.simple.tree プラグイン よりシンプルで互換性の高い無限ツリー plug-in_jquery
ドラッグ:
jquery.simple.tree プラグイン よりシンプルで互換性の高い無限ツリー plug-in_jquery
jquery.simple.tree 公式 Web サイトのアドレス: http://news。 kg/wp -content/uploads/tree/ (開けなくなったようです) ですが、操作は比較的簡単なので、今回はこれを使用します。
前に述べたように、jquery EasyUI Tree プラグインはシンプルで使いやすいですが、テストした結果、まだ多くの欠点があります。
例:
1. IE8 と互換性のある AJAX に問題があります。 。
2. 非同期返信データが遅い場合、読み込み失敗が発生する可能性があります。
3. Tree 関数のみを使用しますが、そのサイズは非常に巨大です。 ...
必要なのは、優れた互換性、非同期、サイズの小ささです (Tree が使用されるシナリオは実際にはほとんどないため、専用のコード ファイルの方が適しています。)
さて、jquery.simple .tree の旅を始めましょう:
まず、CSS、Jquery メイン ファイル、および独自の js ファイルの合計 3 つのファイルを読み込みます。
次に、Tree を定義するコードを読み込みます。
最後に、このルート ノードの HTML コードを記述します。ツリー;
フロントエンド コードは次のとおりです:

コードをコピーします コードは次のとおりです:

;


title> <br><link rel="stylesheet" href="/js/simpletree/jquery.simple.tree.css" /> <br><script type="text/javascript" src="/js /jquery1.4.2.min.js"></script> <br><script type="text/javascript" src="/js/simpletree/jquery.simple.tree.js"></スクリプト> <br><script type="text/javascript"> <br>var simpleTreeCollection <br>$(document).ready(function(){ <br>simpleTreeCollection = $('.simpleTree') simpleTree({ <br>autoclose: true, <br>afterClick:function(node){ <br>alert("選択しました:" $('span:first',node).text() "id は:" $ ('span:first',node).attr("id").substr(2));//ここで「.substr(2)」が必要な理由は、後ほど説明します。テキストを取得する必要がありますが、ここで ID を取得する必要はありません。 <br>}, <br>afterDblClick:function(node){ <br>//alert("text-" $('span:first',node).text());//ダブルクリック イベント<br>} , <br>afterMove:function(destination, source, pos){ <br>//alert("destination-" destination.attr('id') " source-" source.attr('id') " pos -" pos);//イベントをドラッグ<br>}, <br>afterAjax:function() <br>{ <br>//alert('Loaded'); <br>}, <br>animate:true <br>//,docToFolderConvert:true <br>}); <br></script> <br><body> = "simpleTree"> <br><li class="root"><span>地域の選択</span> <br><li id="root0" class=" open"><span>中国</span> <br><ul class="ajax"> <br><li id='0'>{url:/common/GetGroupHtmlByPid.ashx? pid =0}</li> <br></ul> <br></ul> ></body> <br></html> <br><br> <br>バックエンド応答コード: <br>GetGroupHtmlByPid.ashx.cs <br><br><br><br><br>コードをコピーします</div> <br><br> コードは次のとおりです:<br><div class="codebody" id="code56490"> <br>パブリック クラス GetGroupHtmlByPid : IHttpHandler <br>{ <br>GroupManager グループ; <br>public void ProcessRequest(HttpContext context) <br>{ <br>context.Response.ContentType = "text/plain"; <br>int 親 ID = -1; <br>int 型 = 0; <br>文字列結果Str = string.Empty; <br>if (!context.Request.QueryString["pid"].IsNullOrEmpty()) <br>{ <br>Int32.TryParse(context.Request.QueryString["pid"], outparentId); <br>} <br>if (!context.Request.QueryString["type"].IsNullOrEmpty()) <br>{ <br>Int32.TryParse(context.Request.QueryString["type"], out type) ; <br>} <br>if (parentId >= 0) <br>{ <br>try <br>{ <br>group = new GroupManager((GroupType)type); <br>var subAg = group.AllGroups.Where(c => c.ParentId ==parentId); <br>resultStr = "<ul>"; <br>foreach (subAg の Base_group アイテム) <br>{ <br>resultStr = "<li id="" item.GroupId ""><span id="1_" item.GroupId "">" item.GroupName "</span>";//ここでは解読可能です前台番号は何要.substr(2); <br>resultStr = "<ul class='ajax'><li>{url:/common/GetGroupHtmlByPid.ashx?pid=" item.GroupId "}</li></ul>"; <br>resultStr = "</li>"; <br>} <br>resultStr = "</ul>"; <br>} <br>catch (例外例) <br>{ <br>} <br>} <br>context.Response.Write(resultStr); <br>} <br>public bool IsReusable <br>{ <br>get <br>{ <br>return false; <br>} <br>} <br>} <br> </div> <br>后台看起来有点别扭,因為此插件本身只HTML支持节点加下,不过网上有人进行扩展了,用了JSON,不过<br> のすべての jquery.simple.tree アプリケーションの利点: <br> の利点: サイズが小さく、互換性が高く、実行可能で、実行がサポートされています。 <br> 欠点: 初期化の際に大幅な追加が必要な場合は、手動で変更された実行コードが必要になります。後台维护無制限分类,非常方便,有待读者自己去出版,希望本文能够抛砖引玉,对你有所帮助!変更後のダウンロード アドレス: <br>simpletree.rar<br> <br> 最初の初期化時にコンテンツを追加できるように、2 行コードのみを変更しました。</div><div class="nphpQianMsg"><div class="clear"></div></div><div class="nphpQianSheng"><span>声明:</span><div>この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。</div></div></div><div class="nphpSytBox"><span>前の記事:<a class="dBlack" title="jqueryプラグイン開発ノート_jquery" href="http://m.php.cn/ja/faq/21301.html">jqueryプラグイン開発ノート_jquery</a></span><span>次の記事:<a class="dBlack" title="jqueryプラグイン開発ノート_jquery" href="http://m.php.cn/ja/faq/21303.html">jqueryプラグイン開発ノート_jquery</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>関連記事</h2><em><a href="http://m.php.cn/ja/article.html" class="bBlack"><i>続きを見る</i><b></b></a></em><div class="clear"></div></div><ul class="nphpXgwzList"><li><b></b><a href="http://m.php.cn/ja/faq/1609.html" title="Bootstrap リスト グループ コンポーネントの詳細な分析" class="aBlack">Bootstrap リスト グループ コンポーネントの詳細な分析</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/ja/faq/1640.html" title="JavaScript関数のカリー化の詳細説明" class="aBlack">JavaScript関数のカリー化の詳細説明</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/ja/faq/1949.html" title="JS パスワードの生成と強度検出の完全な例 (デモ ソース コードのダウンロード付き)" class="aBlack">JS パスワードの生成と強度検出の完全な例 (デモ ソース コードのダウンロード付き)</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/ja/faq/2248.html" title="Angularjs は WeChat UI (weui) を統合します" class="aBlack">Angularjs は WeChat UI (weui) を統合します</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/ja/faq/2351.html" title="JavaScript を使用して繁体字中国語と簡体字中国語をすばやく切り替える方法と、簡体字中国語と繁体字中国語の切り替えをサポートする Web サイトのトリック_javascript スキル" class="aBlack">JavaScript を使用して繁体字中国語と簡体字中国語をすばやく切り替える方法と、簡体字中国語と繁体字中国語の切り替えをサポートする Web サイトのトリック_javascript スキル</a><div class="clear"></div></li></ul></div></div><div class="nphpFoot"><div class="nphpFootBg"><ul class="nphpFootMenu"><li><a href="http://m.php.cn/ja/"><b class="icon1"></b><p>ホームページ</p></a></li><li><a href="http://m.php.cn/ja/course.html"><b class="icon2"></b><p>コース</p></a></li><li><a href="http://m.php.cn/ja/wenda.html"><b class="icon4"></b><p>に質問</p></a></li><li><a href="http://m.php.cn/ja/login"><b class="icon5"></b><p>私の</p></a></li><div class="clear"></div></ul></div></div><div class="nphpYouBox" style="display: none;"><div class="nphpYouBg"><div class="nphpYouTitle"><span onclick="$('.nphpYouBox').hide()"></span><a href="http://m.php.cn/ja/"></a><div class="clear"></div></div><ul class="nphpYouList"><li><a href="http://m.php.cn/ja/"><b class="icon1"></b><span>ホームページ</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/course.html"><b class="icon2"></b><span>コース</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/article.html"><b class="icon3"></b><span>記事</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/wenda.html"><b class="icon4"></b><span>に質問</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/dic.html"><b class="icon6"></b><span>辞書</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/course/type/99.html"><b class="icon7"></b><span>マニュアル</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/xiazai/"><b class="icon8"></b><span>ダウンロード</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/ja/faq/zt" title="特集"><b class="icon12"></b><span>特集</span><div class="clear"></div></a></li><div class="clear"></div></ul></div></div><div class="nphpDing" style="display: none;"><div class="nphpDinglogo"><a href="http://m.php.cn/ja/"></a></div><div class="nphpNavIn1"><div class="swiper-container nphpNavSwiper1"><div class="swiper-wrapper"><div class="swiper-slide"><a href="http://m.php.cn/ja/" >ホームページ</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/article.html" class="hover">記事</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/wenda.html" >に質問</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/course.html" >コース</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/faq/zt" >特集</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/xiazai" >ダウンロード</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/game" >ゲーム</a></div><div class="swiper-slide"><a href="http://m.php.cn/ja/dic.html" >辞書</a></div><div class="clear"></div></div></div><div class="langadivs" ><a href="javascript:;" class="bg4 bglanguage"></a><div class="langadiv" ><a onclick="javascript:setlang('zh-cn');" class="language course-right-orders chooselan " href="javascript:;"><span>简体中文</span><span>(ZH-CN)</span></a><a onclick="javascript:setlang('en');" class="language course-right-orders chooselan " href="javascript:;"><span>English</span><span>(EN)</span></a><a onclick="javascript:setlang('zh-tw');" class="language course-right-orders chooselan " href="javascript:;"><span>繁体中文</span><span>(ZH-TW)</span></a><a onclick="javascript:;" class="language course-right-orders chooselan chooselanguage" href="javascript:;"><span>日本語</span><span>(JA)</span></a><a onclick="javascript:setlang('ko');" class="language course-right-orders chooselan " href="javascript:;"><span>한국어</span><span>(KO)</span></a><a onclick="javascript:setlang('ms');" class="language course-right-orders chooselan " href="javascript:;"><span>Melayu</span><span>(MS)</span></a><a onclick="javascript:setlang('fr');" class="language course-right-orders chooselan " href="javascript:;"><span>Français</span><span>(FR)</span></a><a onclick="javascript:setlang('de');" class="language course-right-orders chooselan " href="javascript:;"><span>Deutsch</span><span>(DE)</span></a></div></div><script> var swiper = new Swiper('.nphpNavSwiper1', { slidesPerView : 'auto', observer: true,//修改swiper自己或子元素时,自动初始化swiper observeParents: true,//修改swiper的父元素时,自动初始化swiper }); </script></div></div><!--顶部导航 end--><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body></html>