JavaScript + Ajax 実践サンプル集 (1276本以上) ◇編集して実行可能◇
jQueryを使い倒せ! jQueryでAjaxを実装するための基礎知識と実践サンプルを一挙公開中... powered by asp.net 3.5
ホーム
jQuery
jQuery プラグイン
jQuery UI
人気順
カテゴリ
キーワード
クール
新着
ツリー
jQuery PDF
ホット
サイト情報
サイトマップ
★ 新着サンプルトップ50のRSSを購読する
◆ DHTMLサンプル(基礎)のRSSを購読する
◆ DHTMLサンプル(応用)のRSSを購読する
◆ AJAXサンプルのRSSを購読する
◆ その他サンプルのRSSを購読する
◆ BOM(Browser Object Model)のRSSを購読する
◆ DOM(Document Object Model)のRSSを購読する
フォルダーツリーをドラッグ&ドロップして移動
《
プログラマーがネットで副収入を得る方法とは
》
説明
コード
分割コード
関連書籍
コメント投稿
このサンプルは、jQueryのDraggable(), Droppable()プラグインを利用して ツリービューのノードを移動します。ツリービューのノードをドラッグしたら別のノードに移動してみてください。
このサンプルを編集して試してみる
jQuery - Droppable
Folder 1
Subfolder 1 1
Subfolder 1 2
Subfolder 1 2 1
Subfolder 1 2 2
Subfolder 1 2 3
Folder 2
Subfolder 2 1
Subfolder 2 2
外部スクリプト
CSS部
HEAD部
BODY部
ボックス内のコードを外部ファイル(*.js)、またはHTMLドキュメントの<HEAD>セクションの<script>タグ内にコピー&ペーストしてください。
$(function() { tree = $('#myTree'); $('li', tree.get(0)).each( function() { subbranch = $('ul', this); if (subbranch.size() > 0) { if (subbranch.eq(0).css('display') == 'none') { $(this).prepend('
'); } else { $(this).prepend('
'); } } else { $(this).prepend('
'); } } ); $('img.expandImage', tree.get(0)).click( function() { if (this.src.indexOf('spacer') == -1) { subbranch = $('ul', this.parentNode).eq(0); if (subbranch.css('display') == 'none') { subbranch.show(); this.src = 'jQuery/draggableDroppable/images/bullet_toggle_minus.png'; } else { subbranch.hide(); this.src = 'jQuery/draggableDroppable/images/bullet_toggle_plus.png'; } } } ); $('span.textHolder').Droppable( { accept: 'treeItem', hoverclass: 'dropOver', activeclass: 'fakeClass', tollerance: 'pointer', onhover: function(dragged) { if (!this.expanded) { subbranches = $('ul', this.parentNode); if (subbranches.size() > 0) { subbranch = subbranches.eq(0); this.expanded = true; if (subbranch.css('display') == 'none') { var targetBranch = subbranch.get(0); this.expanderTime = window.setTimeout( function() { $(targetBranch).show(); $('img.expandImage', targetBranch.parentNode).eq(0).attr('src', 'jQuery/draggableDroppable/images/bullet_toggle_minus.png'); $.recallDroppables(); }, 500 ); } } } }, onout: function() { if (this.expanderTime) { window.clearTimeout(this.expanderTime); this.expanded = false; } }, ondrop: function(dropped) { if (this.parentNode == dropped) return; if (this.expanderTime) { window.clearTimeout(this.expanderTime); this.expanded = false; } subbranch = $('ul', this.parentNode); if (subbranch.size() == 0) { $(this).after('
'); subbranch = $('ul', this.parentNode); } oldParent = dropped.parentNode; subbranch.eq(0).append(dropped); oldBranches = $('li', oldParent); if (oldBranches.size() == 0) { $('img.expandImage', oldParent.parentNode).src('jQuery/draggableDroppable/images/spacer.gif'); $(oldParent).remove(); } expander = $('img.expandImage', this.parentNode); if (expander.get(0).src.indexOf('spacer') > -1) expander.get(0).src = 'jQuery/draggableDroppable/images/bullet_toggle_minus.png'; } } ); $('li.treeItem').Draggable( { revert: true, autoSize: true, ghosting: true/*, onStop : function() { $('span.textHolder').each( function() { this.expanded = false; } ); }*/ } ); } );
ボックス内のスタイルシート(CSS)を外部ファイル(*.css)、またはHTMLドキュメントの<HEAD>セクションの<style>タグ内にコピー&ペーストしてください。
body { background: #fff; height: 100%; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; min-height: 600px; } .myTree, .myTree ul { list-style: none; padding-left: 22px; } .expandImage { margin-right: 4px; } .folderImage { } .textHolder { height: 16px; line-height: 16px; padding-left: 6px; } span.dropOver { background-color: #00c; color: #fff; height: 16px; line-height: 16px; padding-left: 6px; } .treeItem { list-style: none; }
ボックス内のコードをHTMLドキュメントの<HEAD>セクションにコピー&ペーストしてください。
ボックス内のコードをHTMLドキュメントの<BODY>セクションにコピー&ペーストしてください。
Folder 1
Subfolder 1 1
Subfolder 1 2
Subfolder 1 2 1
Subfolder 1 2 2
Subfolder 1 2 3
Folder 2
Subfolder 2 1
Subfolder 2 2
コメント・提案の投稿!
名前
メール
件名
本文
送信中です...
ASP.NET 3.5
|
Akio's Blog