app/assets/javascripts/pagelet_rails.js in pagelet_rails-0.1.7 vs app/assets/javascripts/pagelet_rails.js in pagelet_rails-0.1.8

- old
+ new

@@ -73,11 +73,11 @@ } }); }; root.loadPagelets = function(selector) { - selector = selector || '[data-widget-url]'; + selector = selector || '[data-pagelet-load]'; var groups = {}; $(selector).each(function(index, elem) { var $el = $(elem); var path = $el.data('widget-url'); @@ -110,17 +110,29 @@ } } } }; - root.pageletArrived = function(id, content) { + root.pageletArrived = function(id, content, tags) { root.placeToContainer(id, content); root.processDataRemoteTags(); + root.tagsChanged(id, tags); $(document).trigger('pagelet-loaded'); }; root.placeToContainer = function(id, content) { - $('#' + id).html(content); + $('#' + id).replaceWith(content); + }; + + root.tagsChanged = function(id, tags) { + if (tags && tags.length > 0) { + var selector = $(); + tags.forEach(function(tag) { + selector = selector.add('[data-pagelet-tags~="' + tag + '"]:not(#' + id + ')'); + }); + + root.loadPagelets(selector); + } }; root.processDataRemoteTags = function() { $('form[data-remote]').each(function(index, elem){ var $el = $(elem);