From 3de45914139d3d7b9d576bd677023d62459c6d3a Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Wed, 3 Apr 2013 17:49:59 +0800 Subject: [PATCH] fix frontend ajax respond 404 due to javascript overwritten after assets precompile --- .../inc/page_widget_edit_interface.js | 38 ++++++++++++++++++ app/assets/javascripts/page_edit.js.erb | 39 ------------------- app/views/admin/page_parts/_edit.html.erb | 5 ++- app/views/admin/page_parts/edit.html.erb | 4 -- app/views/admin/pages/_form.html.erb | 3 +- app/views/admin/pages/edit.html.erb | 2 +- 6 files changed, 44 insertions(+), 47 deletions(-) create mode 100644 app/assets/javascripts/inc/page_widget_edit_interface.js diff --git a/app/assets/javascripts/inc/page_widget_edit_interface.js b/app/assets/javascripts/inc/page_widget_edit_interface.js new file mode 100644 index 000000000..f5b6e62cf --- /dev/null +++ b/app/assets/javascripts/inc/page_widget_edit_interface.js @@ -0,0 +1,38 @@ +function append_id(){ + if ($("#object_id").length == 1) { + return "&id="+$("#object_id").val(); + } + else{ + return ''; + }; +} + +$("div.editable").live("mouseenter mouseleave", function (event) { + $(this).children('.edit_link').toggle(); +}); + +$("#page_design").live('change', function() { + $.getScript($(this).attr('rel') + '?design_id=' + $(this).val() + append_id()); +}); + + +$("#module_app_list select").live('change', function() { + $.getScript($(this).attr('rel') + '?module_app_id='+$(this).val() + append_id()); +}); + +$("#widget_list select,#frontend_list select").live('change', function() { + $.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() + append_id() ); +}); + +$("#tag_list select").live('change', function() { + $.getScript($(this).attr('rel') + '?type=' + $(this).val() + append_id() ); +}); + +$("select.widget_field_select").live('change', function() { + $.getScript($(this).attr('rel') + '?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val() + append_id() ); +}); + +$('.part_kind').live('click', function() { + $('.part_kind_partial').hide(); + $('#part_' + $(this).attr('value')).show(); +}); diff --git a/app/assets/javascripts/page_edit.js.erb b/app/assets/javascripts/page_edit.js.erb index f2b8722f0..9a581a7f4 100644 --- a/app/assets/javascripts/page_edit.js.erb +++ b/app/assets/javascripts/page_edit.js.erb @@ -1,42 +1,3 @@ -function append_id(){ - if ($("#object_id").length == 1) { - return "&id="+$("#object_id").val(); - } - else{ - return ''; - }; -} - -$("div.editable").live("mouseenter mouseleave", function (event) { - $(this).children('.edit_link').toggle(); -}); - -$("#page_design").live('change', function() { - $.getScript($(this).attr('rel') + '?design_id=' + $(this).val() + append_id()); -}); - - -$("#module_app_list select").live('change', function() { - $.getScript($(this).attr('rel') + '?module_app_id='+$(this).val() + append_id()); -}); - -$("#widget_list select,#frontend_list select").live('change', function() { - $.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() + append_id() ); -}); - -$("#tag_list select").live('change', function() { - $.getScript($(this).attr('rel') + '?type=' + $(this).val() + append_id() ); -}); - -$("select.widget_field_select").live('change', function() { - $.getScript($(this).attr('rel') + '?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val() + append_id() ); -}); - -$('.part_kind').live('click', function() { - $('.part_kind_partial').hide(); - $('#part_' + $(this).attr('value')).show(); -}); - $(document).ready(function(){ bindTreeDragHandle(); }); diff --git a/app/views/admin/page_parts/_edit.html.erb b/app/views/admin/page_parts/_edit.html.erb index 79cc057d1..50ebaa7a4 100644 --- a/app/views/admin/page_parts/_edit.html.erb +++ b/app/views/admin/page_parts/_edit.html.erb @@ -19,5 +19,6 @@ <% end %> - -<%=javascript_include_tag "inc/update_cates_and_tags.js" %> \ No newline at end of file + +<%=javascript_include_tag "inc/update_cates_and_tags.js" %> +<%= javascript_include_tag "inc/page_widget_edit_interface.js" %> \ No newline at end of file diff --git a/app/views/admin/page_parts/edit.html.erb b/app/views/admin/page_parts/edit.html.erb index b65781295..907cc7eb0 100644 --- a/app/views/admin/page_parts/edit.html.erb +++ b/app/views/admin/page_parts/edit.html.erb @@ -2,8 +2,4 @@ <%= render 'admin/items/site_map_left_bar' %> <% end -%> - - - - <%= render 'edit' %> \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 0411162ad..559e8be61 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -112,4 +112,5 @@ -<%=javascript_include_tag "inc/update_cates_and_tags.js" %> \ No newline at end of file +<%=javascript_include_tag "inc/update_cates_and_tags.js" %> +<%= javascript_include_tag "inc/page_widget_edit_interface.js" %> \ No newline at end of file diff --git a/app/views/admin/pages/edit.html.erb b/app/views/admin/pages/edit.html.erb index 701b7ae0c..b9029cf8a 100644 --- a/app/views/admin/pages/edit.html.erb +++ b/app/views/admin/pages/edit.html.erb @@ -3,4 +3,4 @@ <%= render 'admin/items/site_map_left_bar' %> <% end -%> -<%= render 'edit' %> \ No newline at end of file +<%= render 'edit' %> \ No newline at end of file