Created
June 2, 2014 08:44
-
-
Save cliffano/b86e7a6ddf4d1c451e3e to your computer and use it in GitHub Desktop.
app.js dynamic list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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