Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery mobile hide button
    primarykey
    data
    text
    <p>I'm developing a mobile website in MVC4/C# and am using a wizard to do some data-input (<a href="http://afana.me/post/create-wizard-in-aspnet-mvc-3.aspx" rel="nofollow">http://afana.me/post/create-wizard-in-aspnet-mvc-3.aspx</a>) I'm also using jQuery v1.8 and jQuery mobile 1.3.1.</p> <p>for some reason I can't get the 'back' button to hide() when initialy showing step 1, moving forward to step2 and back to step1 DOES hide the back button, using this code : </p> <pre><code>$("#back-step").closest('.ui-btn').hide(); </code></pre> <p>when I use the exact same code in $document.ready (or before setting the event-handlers) it doesn't hide the button on the initial view of the page / step.</p> <p>the script code is loaded from a seperate file, loading the script code happens at the bottom of the cshtml file.</p> <pre><code>&lt;script src="~/Scripts/Custom/Wizard.js"&gt;&lt;/script&gt; </code></pre> <p>I'm just wondering what I have to do to get this working, I've searched here and tried various things like $(#back-step").hide$ for hours now, but I can't get it to work correctly. I have put some 'alerts' in my code below to see if the code is 'hit' and it is, so it's beyond me why the button isn't hidden.</p> <p>hope someone here can help, I've included the javascript here below.</p> <p>here's the wizard javascript code:</p> <pre><code>$(function () { $(".wizard-step:first").show(); // show first step $("#back-step").closest('.ui-btn').hide(); alert('hide! first'); // attach nextStep button handler $("#next-step").click(function () { var $step = $(".wizard-step:visible"); // get current step var validator = $("form").validate(); // obtain validator var anyError = false; $step.find("input").each(function () { if (!validator.element(this)) { // validate every input element inside this step anyError = true; } }); if (anyError) return false; // exit if any error found if ($step.next().hasClass("confirm")) { // is it confirmation? try { $("form").submit(); } catch (e) { alert(e.name + ": " + e.message + " " + e.description); } } if ($step.next().hasClass("wizard-step")) { // is there any next step? $step.hide().next().fadeIn(); // show it and hide current step $("#back-step").closest('.ui-btn').show(); } else { // this is last step, submit form $("form").submit(); } }); // attach backStep button handler // hide on first step $("#back-step").click(function () { var $step = $(".wizard-step:visible"); // get current step if ($step.prev().hasClass("wizard-step")) { // is there any previous step? $step.hide().prev().fadeIn(); // show it and hide current step // disable backstep button? if (!$step.prev().prev().hasClass("wizard-step")) { // $step.prev().prev() == $(".wizard-step:first")) { $("#back-step").closest('.ui-btn').hide(); } } else { $("#back-step").closest('.ui-btn').hide(); } }); }); $(document).ready(function () { $("#back-step").closest('.ui-btn').hide(); alert('hide! in ready'); }); </code></pre>
    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