トップ  >  jQueryUI 関連  >  icons と icon [Button Widget] のjQueryUI バージョン違い
Button Widget バージョン違い icons icon
ボタンButton Widget

https://api.jqueryui.com/button/#option-icon

https://api.jqueryui.com/1.8/button/#option-icons

オプション
新 icon

旧 icons
アイコン表示の指定 アイコンクラス名
jQueryUI バージョンにより option 名が異なる

メモ
jQueryUIのバージョン
//ajax.googleapis.com/ajax/libs/jqueryui/
で確認

1.7.1 Button Widget 認識できず
console.log("button icons type = " +  typeof $(btn_elem).button( "option", "icons" ) );
console.log("button icon type = " +  typeof $(btn_elem).button( "option", "icon" ) );


1.8.1 Button Widget 有り
のとき、icons が有効
button icons type = object
button icon type = object

1.12.1 Button Widget 有り
のとき、icons が有効
button icons type = object
button icon type = object

マニュアルでは、icon になっていたが
iconを指定するとエラーになる

iconsを指定すると、正しく動作する

区別ができない
$(btn_elem).button( "option", "icons" ).primary == null
とかも、たぶんだめだろう

エラーになって止まらないように

	/**
	 * init_button_Spread
	 *   /button option setter (jQueryUI 1.12+ or other)
	 *
	 * btn_elem : button element
	 * icon_name : icon class name
	 */
	function optset_button_icon(btn_elem ,icon_name) {
//		console.log("button icons type = " +  typeof $(btn_elem).button( "option", "icons" ).primary );
//		console.log("button icon type = " +  typeof $(btn_elem).button( "option", "icon" ) );
		try{
				$(btn_elem).button( "option", "icons", { primary: icon_name } );
			}catch(e){
				$(btn_elem).button( "option", "icon", { icon: icon_name } );
			}
	}


前
showLabel と text [Button Widget] のjQueryUI バージョン違い
カテゴリートップ
jQueryUI 関連