Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attaching events to dynamically added items #72

Open
maaljam opened this issue Apr 19, 2017 · 1 comment
Open

Attaching events to dynamically added items #72

maaljam opened this issue Apr 19, 2017 · 1 comment

Comments

@maaljam
Copy link

maaljam commented Apr 19, 2017

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.
@nir9
Copy link
Owner

nir9 commented Apr 21, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants