Skip to content

Attaching events to dynamically added items #72

@maaljam

Description

@maaljam

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions