0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Yahoo! UIのOverlayについて

Posted at

ボタンやアイコンをクリックすると、メニューリストを展開できるようにする。

1.必要なYahoo! UIのCSSやJSをインクルードしておく。

2.紐付ける為にSPANタグ等を用意する。IDをつけ忘れないようにする。

sample.html
<SPAN id="menu"></SPAN>

3.javascript側でメニューの設定を行う。

sample.html
	(function () {
		var Event = YAHOO.util.Event;

		Event.onDOMReady(
			function () {
				var oIconMenu = new YAHOO.widget.Overlay('iconmenu', { visible: false });
				var oButton = new YAHOO.widget.Button({
				    type: 'menu',
					id: 'iconpicker',
					label: 'メニュー',
					menu: oIconMenu,
					container: 'menu'
				});

				oButton.on(
					'appendTo', function () {
						oIconMenu.setBody(
                            // メニュー内のHTMLを設定
							"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"80px\" >" + 
							"<tr><td>メニュー項目1</td></tr>" + 
							"<tr><td>メニュー項目2</td></tr>" + 
							"</table>"
						)
					}
				)

				var onOverlayClick = function (p_oEvent){
				oIconMenu.hide();
			};
		
			Event.on(oButton.getMenu().element, 'click', onOverlayClick);
		}
	);
}());
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?