Note that there are some explanatory texts on larger screens.

plurals
  1. PONot saving data with the FormToWizard Jquery plugin
    primarykey
    data
    text
    <p>Im attempting to style this plugin into my rails 3.2 app and having some problems.. <a href="http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx" rel="nofollow">http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx</a></p> <p>The form is not saving to my model when i click submit, just redirects to the first step. ...</p> <p>Heres my view code:</p> <pre><code> &lt;h1&gt;Tell us a little about yourself.&lt;/h1&gt; &lt;form id="SignupForm" action=""&gt; &lt;fieldset&gt; &lt;legend&gt;Personal Information&lt;/legend&gt; &lt;%= simple_form_for @user do |f| %&gt; &lt;%= f.input :city %&gt; &lt;%= f.input :address %&gt; &lt;%= f.input :zipcode %&gt; &lt;%= f.input :date_of_birth, :as =&gt; :date, :start_year =&gt; Date.today.year - 90, :end_year =&gt; Date.today.year - 12, :order =&gt; [:month, :day, :year ] %&gt; &lt;%= f.input :gender, :collection =&gt; ['male','female'] %&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt;Interests &amp; Holidays&lt;/legend&gt; &lt;h2&gt;Select your top 3 interests..&lt;/h2&gt; &lt;label class="checkbox"&gt; &lt;%= f.association :interests, :as =&gt; :check_boxes, :label =&gt; false %&gt; &lt;/label&gt; &lt;br&gt;&lt;/br&gt; &lt;h2&gt;What holidays do you celebrate?&lt;/h2&gt; &lt;label class="checkbox"&gt; &lt;%= f.association :holidays, :as =&gt; :check_boxes, :label =&gt; false %&gt; &lt;/label&gt; &lt;br&gt;&lt;/br&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt;Friends Birthdays&lt;/legend&gt; &lt;h2&gt;Add up to 10 friends birthdays that you would like to remember..&lt;/h2&gt; &lt;br&gt;&lt;/br&gt; &lt;%= f.simple_fields_for :friends do |friend_f| %&gt; &lt;div id="input1" style="margin-bottom:4px;" class="clonedInput"&gt; &lt;%= friend_f.input :name %&gt; &lt;%= friend_f.input :dob, :label =&gt; :Birthday, :as =&gt; :date, :start_year =&gt; Date.today.year - 90, :end_year =&gt; Date.today.year - 12, :order =&gt; [:month, :day, :year ] %&gt; &lt;%= f.input :gender, :collection =&gt; ['male','female'] %&gt; &lt;input type="button" id="btnAdd" value="add another name" /&gt; &lt;input type="button" id="btnDel" value="remove name" /&gt; &lt;/div&gt; &lt;% end %&gt; &lt;%= f.button :submit %&gt; &lt;%end%&gt; &lt;/fieldset&gt; &lt;/div&gt; </code></pre> <p>And heres the js:</p> <pre><code>(function($) { $.fn.formToWizard = function(options) { options = $.extend({ submitButton: "" }, options); var element = this; var steps = $(element).find("fieldset"); var count = steps.size(); var submmitButtonName = "#" + options.submitButton; $(submmitButtonName).hide(); // 2 $(element).before("&lt;ul id='steps'&gt;&lt;/ul&gt;"); steps.each(function(i) { $(this).wrap("&lt;div id='step" + i + "'&gt;&lt;/div&gt;"); $(this).append("&lt;p id='step" + i + "commands'&gt;&lt;/p&gt;"); // 2 var name = $(this).find("legend").html(); $("#steps").append("&lt;li id='stepDesc" + i + "'&gt;Step " + (i + 1) + "&lt;span&gt;" + name + "&lt;/span&gt;&lt;/li&gt;"); if (i == 0) { createNextButton(i); selectStep(i); } else if (i == count - 1) { $("#step" + i).hide(); createPrevButton(i); } else { $("#step" + i).hide(); createPrevButton(i); createNextButton(i); } }); function createPrevButton(i) { var stepName = "step" + i; $("#" + stepName + "commands").append("&lt;a href='#' id='" + stepName + "Prev' class='prev'&gt;&lt; Back&lt;/a&gt;"); $("#" + stepName + "Prev").bind("click", function(e) { $("#" + stepName).hide(); $("#step" + (i - 1)).show(); $(submmitButtonName).hide(); selectStep(i - 1); }); } function createNextButton(i) { var stepName = "step" + i; $("#" + stepName + "commands").append("&lt;a href='#' id='" + stepName + "Next' class='next'&gt;Next &gt;&lt;/a&gt;"); $("#" + stepName + "Next").bind("click", function(e) { $("#" + stepName).hide(); $("#step" + (i + 1)).show(); if (i + 2 == count) $(submmitButtonName).show(); selectStep(i + 1); }); } function selectStep(i) { $("#steps li").removeClass("current"); $("#stepDesc" + i).addClass("current"); } } })(jQuery); </code></pre>
    singulars
    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.
 

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