Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- App.Views.Edit = Backbone.View.extend({
- events: {
- "submit form": "save"
- },
- initialize: function(){
- this.render();
- },
- save: function(){
- var self = this;
- var msg = this.model.isNew() ? 'Successfully created!' : 'Saved!';
- this.model.save({
- title: this.$('[name=title]').val(),
- success: function(model, resp){
- console.log('good');
- new App.Views.Notice({message: msg});
- self.model = model;
- self.render();
- self.delegateEvents();
- Backbone.history.saveLocation('todo_items/'+ model.id);
- $('#edit_area').html('');
- },
- error: function(){
- console.log('bad');
- new App.Views.Error();
- }
- });
- return false;
- },
- render: function(){
- $(this.el).html(ich.edit_form(this.model.toJSON()));
- $('#edit_area').html(this.el);
- }
- });
Add Comment
Please, Sign In to add comment