Skip to content

Instantly share code, notes, and snippets.

@ericeijkelenboom
Last active December 16, 2015 17:59
Show Gist options
  • Save ericeijkelenboom/5474261 to your computer and use it in GitHub Desktop.
Save ericeijkelenboom/5474261 to your computer and use it in GitHub Desktop.
Presentation: building a Single Page App
<table class="table table-hover">
<thead>
<tr>
<th>Campaign name</th>
<th>Number of points before redeem</th>
</tr>
</thead>
<tbody data-bind="foreach: campaigns">
<tr>
<td data-bind="text: description, click: $parent.showDetails"></td>
<td data-bind="text: numberOfPointsBeforeRedeem"></td>
</tr>
</tbody>
</table>
<form>
<label>Description</label>
<input type="text" data-bind="value: description"/>
<label>Number of points before redeem</label>
<input data-bind="value: numberOfPointsBeforeRedeem" type="text" />
<br/>
<button class="btn btn-primary" type="submit" data-bind="click: $parent.save">Save</button>
<button class="btn" type="submit" data-bind="click: $parent.cancel">Cancel</button>
</form>
if (forceRemote)
query = query.using(breeze.FetchStrategy.FromServer);
else
query = query.using(breeze.FetchStrategy.FromLocalCache);
function getCampaigns() {
var query = breeze.EntityQuery.from('Campaigns').orderBy('description');
return mgr.executeQuery(query);
}
function getCampaignById(id) {
return mgr.fetchEntityByKey('Campaign', id, true);
}
function init() {
return mgr.fetchMetadata();
}
function showDetails(campaign) {
router.navigateTo('#details/' + campaign.id());
}
breeze.NamingConvention.camelCase.setAsDefault();
var mgr = new breeze.EntityManager('http://qrcampaign.azurewebsites.net/api/subscriptions');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment