From 1013e216c23cde21ba713557f403e6a27e7c09ff Mon Sep 17 00:00:00 2001 From: Sixfifty Date: Tue, 6 Aug 2013 16:27:04 +0100 Subject: [PATCH] Fixed locale for AJAX requests on addWidget. Currently locale is ignored with AJAX add requests, this patch sends the form locale with the request. --- code/controller/WidgetController.php | 1 - javascript/WidgetAreaEditor.js | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/controller/WidgetController.php b/code/controller/WidgetController.php index 1896296..1008ee5 100644 --- a/code/controller/WidgetController.php +++ b/code/controller/WidgetController.php @@ -99,7 +99,6 @@ class WidgetController extends Controller { if (class_exists('Translatable') && Member::currentUserID()) { // set current locale based on logged in user's locale $locale = Member::currentUser()->Locale; - Translatable::set_current_locale($locale); i18n::set_locale($locale); } if(class_exists($className) && is_subclass_of($className, 'Widget')) { diff --git a/javascript/WidgetAreaEditor.js b/javascript/WidgetAreaEditor.js index 840d5a2..9baf7bb 100644 --- a/javascript/WidgetAreaEditor.js +++ b/javascript/WidgetAreaEditor.js @@ -103,10 +103,15 @@ } } - var parentRef=$(this); + var parentRef=$(this), + locale = $(this).closest('form').find('input[name=Locale]').val(); + $.ajax({ 'url': 'WidgetController/EditableSegment/' + className, - 'success' : function(response) {parentRef.insertWidgetEditor(response)} + 'success' : function(response) {parentRef.insertWidgetEditor(response)}, + 'data' : { + 'locale' : locale , + }, }); }, @@ -177,4 +182,4 @@ } }); }) -})(jQuery); \ No newline at end of file +})(jQuery);