Note that there are some explanatory texts on larger screens.

plurals
  1. POSlideToggle - Delete form data
    text
    copied!<p>I have an expanding form which expands on click, after clicking additional / advanced options become available, now when expanded I also give the option to go back to the normal / basic form. In this case I want to delete everything that was entered in the advanced part of the form. </p> <p>I came as far as this:</p> <pre><code>$(function() { $('#more').hide(); $("#advanced_search").click(function(){ $(this).text($(this).text() == 'Show advanced search options' ? 'Hide advanced search options (selected options will be deleted)' : 'Show advanced search options'); $('#more input').val(''); $('#swimming-pool').prop('checked', false); var select = ("#location"); select.find("option[value='']").attr('selected','selected'); select.data("selectBox-selectBoxIt").refresh(); $('#more').slideToggle(); return false; }); }); </code></pre> <p>The problem I'm facing is that I'm using an additional plugin - selectBoxIt, which makes the selects look better. The problem is if I want to reset the select boxes and just do</p> <p><code>$('#location').val('');</code> </p> <p>then this sets the value, but does not actually change the visible selected option in the select box. Apparently what you have to do is this: </p> <p><code>select.data("selectBox-selectBoxIt").refresh();</code> </p> <p>But as soon as I use that the slideToggle(); goes crazy and stops working (it slides for a split second and goes back up).</p> <p>The advanced part of the form consists of 3 selects: <code>#location #ownership #furniture</code> and some text inputs and a checkbox, they delete just fine, I'm just having trouble with the selects.</p> <p>fiddle demonstrating the slideToggle issue: <a href="http://jsfiddle.net/L3Aux/6" rel="nofollow">jsfiddle.net/L3Aux/6</a></p>
 

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