简体   繁体   中英

Click event is not working for backbone application

I am working on App which has multiple pages. 1. First page:- Get the list of items from server then it created UI according to list of items. It adds the click event on each item. once you click on the item it used appRouter.navigate to go to the detail page of the item. 2. Item detail page: You are at item detail page. Click on back button of history it will go the item list page. Now on item list page click on any item. Click does not work.

It is not working because the content is generated dynamically

You can remove the click event from each item and just assign a class to them. For example .mylist.

$('body').on('click', '.mylist', function(e){
  // DO SOMETHING | YEAH!
});

Goodluck buddy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM