Created
June 6, 2012 03:57
-
-
Save kibaekr/2879813 to your computer and use it in GitHub Desktop.
this ruby loop doesn't work. do i need to do something to allow ruby to work in js.erb?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag(import_missions_path, :method => :post, :id => "import-js", :remote => true ) do |f| %> | |
<ul> | |
<% current_user.folders.find_by_order(1).missions.each do |mission| %> | |
<li> <%= check_box_tag "mission_ids[]", mission.id %> | |
<%= mission.id.to_s + ". " + mission.title %> </li> | |
<% end %> | |
</ul> | |
<%= submit_tag "Import ", :class => 'btn btn-primary' %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class= "fields"> | |
<div class ="well mission"> | |
<div class="mission-head control-group"> | |
<i class="icon-chevron-down" style="float:left;padding:0 5px"></i> | |
<a href="#"> | |
<h3 class="mission-title span5" style="float:left">Mission Title</h4> | |
</a> | |
<i class="icon-remove" style="float:right;padding:0 5px;"></i> | |
<i class="icon-edit" style="float:right;padding:0 5px;"></i> | |
</div> <!-- .mission-head --> | |
<div class="row"> | |
<div class="span6 mission-info"> | |
<%= f.hidden_field :position, :value => "1" %> | |
<div class="control-group"> | |
<%= f.text_field :title, :class =>'row span6' %> | |
<%= f.cktext_area :content, :toolbar => 'MyToolbar', :class => 'row span6', :rows => '5', :placeholder => "What is the first step a learner should do? (e.g. Watch an intro video, read certain article)" %> | |
</div> | |
</div><!-- .mission-info --> | |
</div> | |
</div> <!-- .mission --> | |
</div> <!-- fields --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert('<%= escape_javascript(@missions_hash.inspect) %>'); | |
//loop for each mission passed in | |
<% @mission_hash.each do |mission| %> | |
//click add missions | |
$('#add-missions-button').trigger('click'); | |
//pass in mission.title & mission.content to form textbox value in _missions_fields.html.erb | |
//HOW? - textbox :title = mission.title | |
//HOW? - textbox :content = mission.content | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def import | |
#@syllabus = Syllabus.find(params[:syllabus_id]) | |
@missions_hash = [] | |
#loop through each mission id from :missions_id | |
params[:mission_ids].each do |id| | |
@missions_hash << Mission.find(id) | |
end | |
respond_to do |format| | |
format.html { redirect_to edit_syllabus_path(@syllabus), notice: "imported" } | |
format.js { render 'folders/import.js.erb' } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment