i create a sample app that using Local Storage Adapter : the hbs code is :
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
<input type="button" {{action cr}} value="Create"/>
<ul>
{{#each item in model}}
<li>{{item.name}}</li>
{{else}}
NO Item
{{/each}}
<ul>
</script>
and the app.js file is :
App = Ember.Application.create();
App.LSAdapter = DS.LSAdapter.extend({
namespace: 'app'
});
App.ApplicationAdapter = DS.LSAdapter;
App.Router.map(function() {
});
App.Store = DS.Store.extend();
App.store = App.Store.create();
App.Item = DS.Model.extend({
name:DS.attr('string'),
uniqueName:DS.attr('string')
});
App.ApplicationRoute = Ember.Route.extend({
model:function(){
return this.get('store').findAll('item');
}
});
App.IndexRoute = Ember.Route.extend({
model:function(){
return this.get('store').findAll('item');
}
});
App.Item.reopen({
url:'localhost/app/'
});
App.ApplicationController = Ember.ArrayController.extend({
actions:{
cr:function(){
this.get('store').createRecord('item',{
id:Math.random().toString(32).slice(2).substr(0, 5),
name:'Hello',
uniqueName:'Hello 2'
});
App.store.commit();
}
}
});
but i get an error :
Uncaught TypeError: Object [object Object] has no method 'commit'
i am using emberjs 1.0 and last ember data build.i want to save records to local storage and i cant find any sample out there.