Note that there are some explanatory texts on larger screens.

plurals
  1. PORadio button change firing twice
    primarykey
    data
    text
    <p>I've got a group of radio buttons. When the radio buttons are changed an event is fired. A check is made to see if a certain radio button was selected, if so a text box is displayed.</p> <pre><code>&lt;div class="row"&gt; &lt;div class="span3"&gt; &lt;label&gt;@Html.RadioButtonFor(model =&gt; model.HearAboutUs, "radWebsite", new { @id = "radWebsite" }) Website&lt;/label&gt; &lt;label&gt;@Html.RadioButtonFor(model =&gt; model.HearAboutUs, "radFromEmployee", new { @id = "radFromEmployee" }) An employee&lt;/label&gt; &lt;label&gt;@Html.RadioButtonFor(model =&gt; model.HearAboutUs, "radEvent", new { @id = "radEvent" }) At an event&lt;/label&gt; ... &lt;label&gt;@Html.RadioButtonFor(model =&gt; model.HearAboutUs, "radOther", new { @id = "radOther" }) Other&lt;/label&gt; &lt;/div&gt; &lt;div class="span3"&gt; @Html.ValidationMessageFor(model =&gt; model.HearAboutUs) &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The script:</p> <pre><code>$('input:radio[name="HearAboutUs"]').change(function () { $('input[type=radio].input-validation-error').parent().removeClass('error-label'); if ($('#radOther').is(':checked')) { if ($('#HearAboutUsDescription').is(':hidden')) { $('#HearAboutUsDescription').show("blind"); } } else { if ($('#HearAboutUsDescription').is(':visible')) { $('#HearAboutUsDescription').hide("blind"); $('#HearAboutUsDescription').val(''); } } }); </code></pre> <p>This works fine! However... This is a partial page that is being hidden and un-hidden when the user presses next/back respectively. After pressing next, and then back. The script to hide the text box somehow gets called twice!?! Not when it's shown however. The code for the next/back which is on a main index page:</p> <pre><code>$('#nextBtn').click(function () { $('#panel1').hide("", function () { $('#panel2').show("blind"); $('#backBtn').show(); }); }); $('#backBtn').click(function () { if ($('#panel2').is(":visible")) { $('#headerTitle').text("Your Details"); $('#panel2').hide("", function() { $('#panel1').show("blind"); $('#backBtn').hide(); }); } if ($('#panel3').is(":visible")) { $('#headerTitle').text("About Your Home"); $('#panel3').hide("", function() { $('#panel2').show("blind"); }); } if ($('#panel4').is(":visible")) { $('#headerTitle').text("Water Use In The House"); $('#panel4').hide("", function() { $('#panel3').show("blind"); $('#nextBtn').show(); $('#nextBtn').html("Next"); }); } }); </code></pre> <p>Any ideas as to what I could be doing wrong? I'm going slightly mad with this, heh :) Thanks</p> <p>Edit = just noticed I pasted the next btn twice, replaced with back button. Also the buttons are on the index page, not the partial page.</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