itemslide icon indicating copy to clipboard operation
itemslide copied to clipboard

Attaching events to dynamically added items

Open maaljam opened this issue 7 years ago • 1 comments

Problem Most data binding libraries like knockout and Angular allow to dynamically add DOM elements. When this happens, itemslide does not attach events to the newly added items.

example

<div id="carousel">
  <li ng-repeat="item in items" ng-bind="item.label"></li>
</div>

/* JS */
$scope.items = [
{label: "one"},{label: "two"},
];

$scope.items.push(,{label: "new item"});

Note: I am aware that addSlide can be used but this defeats the purpose of using such libraries and frameworks.

Possbile solutions

  1. Somehow listening to the carousel DOM item changes and attach events when change is detected.
  2. Extending itemslide with a new method that calls carousel.nav.createEvents(); and slides.reload(); so users call it after they change the array of items, ie add items.

maaljam avatar Apr 19 '17 17:04 maaljam

i'll update reload so that it will call createEvents as well so that the user can call reload when changing the array of items.

nir9 avatar Apr 21 '17 16:04 nir9