Skip to content

Instantly share code, notes, and snippets.

@cliffano
Created June 2, 2014 08:44
Show Gist options
  • Save cliffano/b86e7a6ddf4d1c451e3e to your computer and use it in GitHub Desktop.
Save cliffano/b86e7a6ddf4d1c451e3e to your computer and use it in GitHub Desktop.
app.js dynamic list
The html page:
<div class="app-page" data-page="blah">
<div class="app-topbar">
<div class="app-title">Blah</div>
</div>
<div class="app-content">
<ul id="somelist" class="app-list">
<li class="app-button" data-target="sometarget">Foo</li>
</ul>
</div>
</div>
The populator:
App.populator('blah', function (page) {
$.getJSON('/data/', function (data) {
Object.keys(data).forEach(function (id) {
$(page).find('#somelist').append(
'<li class="app-button" data-target="sometarget">' + data[id] + '</li>'
);
});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment