Note that there are some explanatory texts on larger screens.

plurals
  1. POReset jquery ui selectmenu dropdown to default option
    primarykey
    data
    text
    <p>I have a dropdown select menu rendered via this code</p> <pre><code>@Html.DropDownListFor(m =&gt; m.OwnedItemId, Model.Plans, "Select a plan type", new {@class = "selectMenu", id="addPlanSelectmenu"}) </code></pre> <p>In the view it looks something like this:</p> <pre><code>&lt;select class="selectMenu" data-val="true" data-val-number="The field OwnedItemId must be a number." id="addPlanSelectmenu" name="OwnedItemId" aria-disabled="false" style="display: none;"&gt; &lt;option value=""&gt;Select a plan type&lt;/option&gt; &lt;option value="143863"&gt;RetirementSaving (143863)&lt;/option&gt; &lt;option value="143876"&gt;BankAccount (143876)&lt;/option&gt; &lt;option value="143913"&gt;RetirementSaving (143913)&lt;/option&gt; &lt;option value="143929"&gt;RetirementSaving (143929)&lt;/option&gt; &lt;option value="144030"&gt;BankAccount (144030)&lt;/option&gt; ... &lt;/select&gt; </code></pre> <p>I would like to go to the default option after submitting but I can't make it work. So far I have tried quite a few things, like the one proposed <a href="https://stackoverflow.com/a/11031313/1179061">in this answer</a>, using</p> <pre><code>$('#addPlanSelectmenu').selectmenu("value", ""); </code></pre> <p>Funny enough to my understanding if I do something like this</p> <pre><code>$('#addPlanSelectmenu').selectmenu("value", null); //Or an unexisting value </code></pre> <p>it goes back to the last option of the list.</p> <p>Any idea?</p> <p>Thanks</p> <p>Edit: I forgot to mention that I guess a clean way is just adding a value to the default text, but I don't even know if it's possible with these helpers</p> <p>Edit 2: I eventually made it work using this <a href="https://stackoverflow.com/a/10471838/1179061">answer</a></p>
    singulars
    1. This table or related slice is empty.
    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.
    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