<%= stylesheet_link_tag "select2/select2" %> <%= javascript_include_tag 'validator' %> <%= javascript_include_tag "select2/select2.min" %> <% content_for :page_specific_css do %> <%= stylesheet_link_tag "lib/main-forms" %> <% end %> <%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms page_part_form_validate"} do |f| %> <input type="hidden" name="part_id" value="<%= @part.id.to_s %>" /> <input type="hidden" name="page_id" value="<%= params[:page_id] %>" /> <% if OrbitHelper.is_mobile_view %> <input class="hidden_page_id" name="mobile_view" type="hidden" value="1"> <% end %> <%= render :partial => "form", :locals => { :f => f } %> <% end %> <script> $("select.module_name").on("change",function(){ var select = $(this), widget_area = $("#widgets_selection_area"); if(select.val()){ $.ajax({ url : "/page_parts/getwidgets", dataType : "html", data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part_number %>, "mobile_view" : <%= OrbitHelper.is_mobile_view ? "1" : "null" %>}, type : "get" }).done(function(html){ widget_area.html(html); }) } }) $("form").on("ajax:success",function(){ <% url = Page.find(params[:page_id]).url %> var url = "/<%= I18n.locale.to_s if url != '/' %><%= url if url != '/' %>?editmode=on<%= OrbitHelper.is_mobile_view ? '&mobile_view=1'.html_safe : '' %>"; window.location.href = url; }) </script>