javascript - How do I initialize list.js after a dynamically-created list is rendered? -
sadly, list.js
isn't filtering list @ all. i'm assuming it's because elements not in dom when javascript called.
var render = function(list, arr){ arr.foreach(function(coder){ var context = { logo:coder.logo, name:coder.displayname, status:coder.status, status_icon:coder.status_icon, url:coder.url}; var html = template(context); $(list).append(html); }) var options = { valuenames: [ 'name' ] }; var hackerlist = new list('hacker-list', options); } ... render('#all',all); render('#offline', offline); render('#online', online);
you can see in last 2 lines, attempting call code after foreach finished appending elements (handlebar templates). not working me either.
here surrounding html.
<div class='container' id='main-list'> <div id='hacker-list' class=""> <ul class="row list" > <li id='_all' class="btn btn-default col-xs-4 arrow_box all">all</li> <li id='_online' class="btn btn-default col-xs-4 online">online</li> <li id='_offline' class="btn btn-default col-xs-4 offline">offline</li> </ul> </div> <input class="search" /> <div class='panel' id="all"></div> <div class='panel' id="online"></div> <div class='panel' id="offline"></div> </div> <script src="http://listjs.com/no-cdn/list.js"></script>
could last line in code 1 firing early? not common problem? doesn't seem searching through questions...
render('#all',all); render('#offline', offline); render('#online', online);
in all
, offline
, , online
variables. set somewhere? have error in console saying not defined if look.
per documentation http://www.listjs.com/docs second argument options , should contain object. how have setup?
Comments
Post a Comment