diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index eb67ca4f235..177f3dcc925 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -957,7 +957,14 @@ options.registry.Carousel = options.Class.extend({ const id = 'myCarousel' + Date.now(); this.$target.attr('id', id); this.$target.find('[data-target]').attr('data-target', '#' + id); - this.$target.find('[data-slide]').attr('href', '#' + id); + _.each(this.$target.find('[data-slide], [data-slide-to]'), function (el) { + var $el = $(el); + if ($el.attr('data-target')) { + $el.attr('data-target', '#' + id); + } else if ($el.attr('href')) { + $el.attr('href', '#' + id); + } + }); }, }); diff --git a/addons/website/static/src/snippets/s_image_gallery/options.js b/addons/website/static/src/snippets/s_image_gallery/options.js index cbbadb6ea50..e796b5a16d3 100644 --- a/addons/website/static/src/snippets/s_image_gallery/options.js +++ b/addons/website/static/src/snippets/s_image_gallery/options.js @@ -56,9 +56,13 @@ options.registry.gallery = options.Class.extend({ * @override */ onBuilt: function () { - var uuid = new Date().getTime(); - this.$target.find('.carousel').attr('id', 'slideshow_' + uuid); - this.$target.find('[data-target]').attr('data-target', '#slideshow_' + uuid); + this._adaptNavigationIDs(); + }, + /** + * @override + */ + onClone: function () { + this._adaptNavigationIDs(); }, /** * @override @@ -331,6 +335,21 @@ options.registry.gallery = options.Class.extend({ // Private //-------------------------------------------------------------------------- + /** + * @private + */ + _adaptNavigationIDs: function () { + var uuid = new Date().getTime(); + this.$target.find('.carousel').attr('id', 'slideshow_' + uuid); + _.each(this.$target.find('[data-slide], [data-slide-to]'), function (el) { + var $el = $(el); + if ($el.attr('data-target')) { + $el.attr('data-target', '#slideshow_' + uuid); + } else if ($el.attr('href')) { + $el.attr('href', '#slideshow_' + uuid); + } + }); + }, /** * @override */