From c5854870424d87372bcc86a7edf75b9bf8841825 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 18 Nov 2010 16:13:34 +0000 Subject: Refs #1793 added ability to add widgets to layout through ajax git-svn-id: http://code.elgg.org/elgg/trunk@7338 36083f99-b078-4883-b0ff-0f9b5a30f544 --- js/lib/ui.widgets.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index f4fa4b256..b1e7b2a99 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -14,9 +14,26 @@ elgg.ui.widgets.init = function() { event.preventDefault(); }); - + $('.widgets_add a').bind('click', function(event) { + elgg.action('widgets/add', { + data: { + handler: $(this).attr('id'), + user: elgg.get_loggedin_userid(), + context: $("input[name='widget_context']").val() + }, + success: function(json) { + elgg.ui.widgets.insert(json.output); + } + }); + event.preventDefault(); + }); }; +// insert a widget into the layout +elgg.ui.widgets.insert = function(html) { + $('.widget_first_col').prepend(html); +} + //List active widgets for each page column elgg.ui.widgets.outputList = function(forElement) { return $("input[name='handler'], input[name='guid']", forElement).makeDelimitedList("value"); -- cgit v1.2.3