2017-04-01 41 views

回答

0

我可能有點晚,但我只是在使用這些相同功能的項目上工作,所以如果有其他人想知道同樣的事情,希望這可能會有所幫助。

一般來說,最好設置妖獸就像你會爲一個普通的HTML嚮導:

應用程序/控制器/ set_up_positions_controller.rb

class SetUpPositionController < ApplicationController 

    include Wicked::Wizard 

    steps :appointment_settings, :lab_settings 

    def show 
     case step 
     when :appointment_settings 
     when :lab_settings 
     end 
     render_wizard 
    end 

    def update 
     case step 
     when :appointment_settings 
      #LOGIC 
     when :lab_settings 
      #LOGIC 
     end 
     render_wizard @position 
    end 

end 

從這裏的關鍵是要建立一個既step_name.js.erb和每個步驟的_step_name.html.erb文件。 IE瀏覽器。

應用程序/視圖/ set_up_positions/appointment_settings.js.erb

$('#clinics-content').html('<%= j render "clinic_management/set_up_position/appointment_settings" %>'); 

應用程序/視圖/ set_up_positions/_appointment_settings.html.erb

<%= simple_form_for [:clinic_management, @clinic, @position], url: wizard_path, method: :put, remote: true do |f| %> 
    <%= f.input :bill_authorization, collection: bill_authorization_options %> 
    #etc etc 
<% end%> 

你可能會想一些錯誤添加使用JS文件進行消息傳遞(現在它調用相同的JS,並在字段名稱下呈現錯誤,在這種情況下可能會或可能不會)。

根據你的用例,它可能也更容易使用這種類型的東西(如steps.js)的JS框架之一。我沒有,因爲我明白ruby比JS好一點,但對於其他人來說,這也是一種選擇。

相關問題