当前位置: 代码迷 >> Web前端 >> jQuery 插件私有属性的调用(UI 替列)
  详细解决方案

jQuery 插件私有属性的调用(UI 替列)

热度:74   发布时间:2012-11-25 11:44:31.0
jQuery 插件私有属性的调用(UI 为列)

(function( $ ) {
	$.widget( "ui.combobox", {
		create: function() {
		var self = this,
		select = this.element.hide(),
		selected = select.children( ":selected" ),
		value = selected.val() ? selected.text() : "";
	var input = this.input = $( "<input>" )
		insertAfter( select )
		.val( value )
		.autocomplete({ ....//以下省略
   
   //需要实现在页面无刷新的情况下 重新加载组件
   $("#test").click(function(){
        //通过创建 原型(函数) 调用组件下方法
	$.ui.combobox.prototype.create = function(){
	   this._create();
	};
	
	$("#combobox option:eq("+ Rand +")").attr("selected", true);
	$("#combobox").parent().find("input,button").remove();
	$( "#combobox" ).combobox("create");
    });

    <div class="ui-widget">
	<label>Your preferred programming language: </label>
	<select id="combobox">
		<option value="">Select one...</option>
		<option value="ActionScript">ActionScript</option>
		<option value="AppleScript">AppleScript</option>
		<option value="Asp">Asp</option>
		<option value="BASIC">BASIC</option>
		<option value="C">C</option>
		<option value="C++">C++</option>
		<option value="Clojure">Clojure</option>
		<option value="COBOL">COBOL</option>
		<option value="ColdFusion">ColdFusion</option>
		
	</select>
    </div>
<button id="test" >Test</button>

  相关解决方案