2016-09-01 2 views
0

내가 추가 한 UI를 jQuery의 selectmenu 자리가 오류를JQuery와 UI를 selectmenu 자리가

$.widget('app.selectmenu', $.ui.selectmenu, { 
    _drawButton: function() { 
     this._super(); 
     var selected = this.element 
       .find('[selected]') 
       .length, 
      placeholder = this.options.placeholder; 

     if (!selected && placeholder) { 
      this.buttonText.text(placeholder);  
     } 
    } 
}); 

$('select').selectmenu({ 
    placeholder: 'Select a speed' 
}); 

오류를 보여주는 작동하지 작동하지 않는 것은 text is not defined입니다.

this.buttonItem.text(placeholder); 

- 버튼이하는 존재 :

this.buttonText.text(placeholder); 

시도에 : 나는 1.12.0

답변

1

대신 JQuery와 UI 버전을 사용하고 있습니다 만 버튼 buttonItem을 가지고 buttonItem가 변경 데 필요한 본문.

예 :

$.widget('app.selectmenu', $.ui.selectmenu, { 
 
    _drawButton: function() { 
 
    this._super(); 
 
    var selected = this.element 
 
    .find('[selected]') 
 
    .length, 
 
     placeholder = this.options.placeholder; 
 

 
    if (!selected && placeholder) { 
 
     this.buttonItem.text(placeholder); 
 
    } 
 
    } 
 
}); 
 
$(function() { 
 
    $('#speed').selectmenu({ placeholder: 'Select a speed' }); 
 
});
<link href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" rel="stylesheet"/> 
 
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> 
 
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script> 
 

 
<label for="speed">Select a speed</label> 
 
<select name="speed" id="speed"> 
 
    <option>Slower</option> 
 
    <option>Slow</option> 
 
    <option>Medium</option> 
 
    <option>Fast</option> 
 
    <option>Faster</option> 
 
</select>

관련 문제