Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving Jquery ui issue
    primarykey
    data
    text
    <p>I placed all code below. My page works like that</p> <p>Page's first scene <img src="https://i.stack.imgur.com/eAVBD.png" alt="enter image description here"></p> <p>When i choose something from #menu it fires <code>$("#menu").change(function ()</code> function and i'm getting scene like that <img src="https://i.stack.imgur.com/36ydS.png" alt="enter image description here"> Radio buttons <code>.parentcheck</code> are located in div #options. They're like turn off (first one)/on (second one) select-box <code>#parent</code>.</p> <p>When i turn <code>#parent</code>selectbox on, it fires genopts- ajax request and on success it transforms select-box into <a href="http://jqueryui.com/demos/autocomplete/#combobox" rel="nofollow noreferrer">jquery-ui autocomplete combobox</a> and places default value.</p> <p><img src="https://i.stack.imgur.com/sIfBn.png" alt="enter image description here"></p> <p><strong>Now, the problem is following</strong></p> <ul> <li>I'm using <code>input.val( $("#parent option:selected").text());</code> (in combobox configuration) to place default value. The problem is i want to remove this text onclick (something like html5 placeholder but i want crossbrowser support). How to modify the combobox configuration part to fix that problem?</li> </ul> <p>HTML Markup</p> <pre><code> &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="menu" id="menu_label"&gt;Səhifə harada yerləşəcək?&lt;/label&gt; &lt;select name="menu" id="menu"&gt; &lt;option value="" selected="selected"&gt;Birini seçin...&lt;/option&gt; &lt;option value="1"&gt;Header menyuya əlavə et&lt;/option&gt; &lt;option value="2"&gt;Footer menyuya əlavə et&lt;/option&gt; &lt;option value="0"&gt;Bu səhhifənin menyuda adı olmayacaq&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;td&gt;&lt;div id="options"&gt; &lt;input type="radio" class="parentcheck" name="parentcheck" value="0"/&gt; Ayrıca yoxsa &lt;input type="radio" class="parentcheck" name="parentcheck" value="1"/&gt; hansısa başlıq altında? &lt;/div&gt; &lt;select name="parent" id="parent"&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>The combobox configuration</p> <pre><code>(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 = $( "&lt;input&gt;" ) .insertAfter( select ) .val( value ) .autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value &amp;&amp; ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&amp;;]+;)(?!&lt;[^&lt;&gt;]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^&lt;&gt;]*&gt;)(?![^&amp;;]+;)", "gi" ), "&lt;strong&gt;$1&lt;/strong&gt;" ), value: text, option: this }; }) ); }, select: function( event, ui ) { ui.item.option.selected = true; self._trigger( "selected", event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; } }); if ( !valid ) { // remove invalid value, as it didn't match anything $( this ).val( "" ); select.val( "" ); input.data( "autocomplete" ).term = ""; return false; } } } }) .addClass( "ui-widget ui-widget-content ui-corner-left" ); input.val( $("#parent option:selected").text()); input.data( "autocomplete" )._renderItem = function( ul, item ) { return $( "&lt;li&gt;&lt;/li&gt;" ) .data( "item.autocomplete", item ) .append( "&lt;a&gt;" + item.label + "&lt;/a&gt;" ) .appendTo( ul ); }; this.button = $( "&lt;button type='button'&gt;&amp;nbsp;&lt;/button&gt;" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .insertAfter( input ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "ui-corner-right ui-button-icon" ) .click(function() { // close if already visible if ( input.autocomplete( "widget" ).is( ":visible" ) ) { input.autocomplete( "close" ); return; } // work around a bug (likely same cause as #5265) $( this ).blur(); // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); input.focus(); }); }, destroy: function() { this.input.remove(); this.button.remove(); this.element.show(); $.Widget.prototype.destroy.call( this ); } }); })( jQuery ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload