トップ  >  jQueryUI 関連  >  showLabel と text [Button Widget] のjQueryUI バージョン違い
Button Widget バージョン違い showLabel text
ボタンButton Widget
https://api.jqueryui.com/button/#option-showLabel
オプション

新 showLabel

旧 text

ラベルを表示するか、しないかの指定 boolean
jQueryUI バージョンにより option 名が異なる

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

1.7.1 Button Widget 認識できず
if (typeof $(エレメント).button == "function" ) {
   btn_Widget_alive = true;
略
}
で処理を分岐して、ボタンの表示処理をスキップ

console.log("button showLabel type = " +  typeof $(btn_elem).button( "option", "showLabel" ) );
console.log("button text type = " +  typeof $(btn_elem).button( "option", "text" ) );

1.8.1 Button Widget 有り
のとき、text が有効
button showLabel type = object
button text type = boolean

showLabelを指定するとエラーになりスクリプト停止

1.12.1 Button Widget 有り
のとき、showLabel が有効
button showLabel type = boolean
button text type = boolean

textを指定してもエラーで止まらないが
指定は有効にならない
どうやって区別しようか、
エラーになって止まらないように

	/**
	 * optset_button_showLabel
	 *   /button option setter (jQueryUI 1.12+ or other)
	 *
	 * btn_elem : button element
	 * show_flag : true or false
	 * https://api.jqueryui.com/button/#option-showLabel
	 */
	function optset_button_showLabel(btn_elem ,show_flag) {
//		console.log("button showLabel type = " +  typeof $(btn_elem).button( "option", "showLabel" ) );
//		console.log("button text type = " +  typeof $(btn_elem).button( "option", "text" ) );
		//jQueryUI 1.12+
		try{
			if ( typeof $(btn_elem).button( "option", "showLabel" ) == "boolean" ){
				$(btn_elem).button( "option", "showLabel", show_flag );
			} else {
				$(btn_elem).button( "option", "text", show_flag );
			}
		}catch(e){
			$(btn_elem).button( "option", "text", show_flag );
		}

	}


前
ui-widget-content の background-colorと透明色
カテゴリートップ
jQueryUI 関連
次
icons と icon [Button Widget] のjQueryUI バージョン違い