Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging Custom Forms Dropdown programatically using Zurb Foundation
    primarykey
    data
    text
    <p>I would like to change the dropdown field. Which is quite easy with a normal one, but Foundation replaces it with a custom dropdown field.</p> <p>Here the HTML-Code:</p> <pre><code>&lt;div class="row"&gt; &lt;div class="small-centered columns"&gt; &lt;select name="language" id='customDropdown' class='large languageDropdown'&gt; &lt;option value="de"&gt;German&lt;/option&gt; &lt;option value="en"&gt;English&lt;/option&gt; &lt;option value="ca"&gt;Castelliano&lt;/option&gt; &lt;option value="es"&gt;Spanisch&lt;/option&gt; &lt;option value="fr"&gt;Französisch&lt;/option&gt; &lt;option value="pt"&gt;Portugisisch&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This is what foundation makes out of it:</p> <pre><code>&lt;div class="row"&gt; &lt;div class="small-centered columns"&gt; &lt;select name="language" id="customDropdown" class="large languageDropdown hidden-field" data-id="1375994037026-oNYTe"&gt; &lt;option value="de"&gt;German&lt;/option&gt; &lt;option value="en"&gt;English&lt;/option&gt; &lt;option value="ca"&gt;Castelliano&lt;/option&gt; &lt;option value="es"&gt;Spanisch&lt;/option&gt; &lt;option value="fr"&gt;Französisch&lt;/option&gt; &lt;option value="pt"&gt;Portugisisch&lt;/option&gt; &lt;/select&gt; &lt;div class="custom dropdown large languageDropdown" data-id="1375994037026-oNYTe"&gt; &lt;a href="#" class="current"&gt;German&lt;/a&gt; &lt;a href="#" class="selector"&gt;&lt;/a&gt; &lt;ul&gt; &lt;li class="selected"&gt;German&lt;/li&gt; &lt;li class=""&gt;English&lt;/li&gt; &lt;li class=""&gt;Castelliano&lt;/li&gt; &lt;li class=""&gt;Spanisch&lt;/li&gt; &lt;li class=""&gt;Französisch&lt;/li&gt; &lt;li class=""&gt;Portugisisch&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>My Javascript attemts:</p> <p>1. $('#customDropdown').val(jd.language);</p> <p>Works fine - but only with the hidden field - if I send the form the correct language is send to the server. But the visible DropDown Field still shows the old value.</p> <p>2. $('#customDropdown').val(jd.language).trigger('change');</p> <p>Unfortunately that does not work - even it works like charm over <a href="http://www.massivedesigns.com/misc/zurb/index.html" rel="nofollow">here</a> - can't find out why it does not work with my code.</p> <p>3. $('#customDropdown').val(jd.language).change(); Foundation.libs.forms.refresh_custom_select('.languageDropdown', true);</p> <p>This throws a Javascript error: </p> <blockquote> <p>Uncaught TypeError: Object .languageDropdown has no method 'next' </p> </blockquote> <p>4. $('#customDropdown').val(jd.language); $(document).foundation(); </p> <p>Thought it will refresh the foundation javascript, but it doesn't. ... </p> <p>Running out of ideas (maybe I oversee sth.? - That's what I hope you guys could help me to find) One interesting thing, though: If I submit the form, I am redirected to a submit-page. If I use the browser button to go back: .... VOILA! - The correct dropdown field is shown. But that's not quite what I want :P</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.
    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