java - JSP + JQuery UI Selectmenu + default text -


i have next select on view:

<div class="sort">     <label for="sort"><span>sort by:</span></label>     <select name="sort" id="sort">         <option selected="selected" disabled="disabled" style="display:none;">choose...</option>         <option             <c:if test="${pagination.sorton eq 'time' , pagination.asc}">selected="selected"</c:if>             data-text="desc" value="time"             data-order="asc">             desc         </option>         <option             <c:if test="${pagination.sorton eq 'time' , not pagination.asc}">selected="selected"</c:if>             data-text="asc" />" value="time"             data-order="desc">             asc         </option>     </select> </div> 

this how place jquery widget on select:

$('#sort').goodslistselect({         width : 180,         appendto : ".sort",         change : function() {             var option = $(this).find(":selected:not([disabled])");             if (option.val()) {                 utils.reloadwithparams({                     "page" : 1,                     "sort" : option.val(),                     "order" : option.attr("data-order")                 });             }         }     }); 

the problem cant working first option "choose...". should displaying if user not choosen other option.

i've tried following answers, not working me:

  1. html select: how set default text won't shown in drop-down list?

  2. how show disable html select option in default?

how such behavior may achieved ?

in general, override selectmenu widget this

jquery.widget(     'custom.selectmenu_with_title',     $.ui.selectmenu,     {         _settext: function( element, value ) {             if (element.hasclass('ui-selectmenu-text')) {                 element.text('whatever should title');             } else if ( value ) {                 element.text( value );             } else {                 element.html( "&#160;" );             }         }     } ); 

and call 1 instead original.

$('#sort').selectmenu_with_title(....); 

in special case, not use orignial selectmenu widget, custom version called goodslistselect. - insert custom _settext method definition of custom widget.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -