Skip to content

Instantly share code, notes, and snippets.

@techhahn
Created February 24, 2013 16:11
Show Gist options
  • Select an option

  • Save techhahn/5024359 to your computer and use it in GitHub Desktop.

Select an option

Save techhahn/5024359 to your computer and use it in GitHub Desktop.
require.config({
paths: {
jquery: 'lib/jquery',
backbone: 'lib/backbone',
underscore: 'lib/underscore'
}
})
define(['jquery', 'underscore', 'backbone', 'text!templates/editprofile.html'], function($, _, backbone, editProfileTemplate) {
var editProfile = Backbone.View.extend({
el: $('#renderarea'),
initialize: function() {
_.bindAll(this);
},
template: _.template(editProfileTemplate),
render: function() {
this.$el.html( this.template(this.model.toJSON()) )
return this;
}
})
return {
editProfile: editProfile
}
})
app_router.on('route:showEditProfile', function() {
var user = new User.User();
var editprofile = new editProfileView.editProfile({ model: user})
user.fetch().then(editprofile.render());
}
});
define(['backbone'], function(backbone) {
console.log('User model initialized');
var
User = Backbone.Model.extend({
urlRoot : '/user_API',
defaults: {
username: '',
first_name: '',
last_name: '',
user_email: '',
user_photo: '/assets/img/defuser.jpg'
},
userImage: function() {
return "/assets/img/" + this.get('user_photo');
},
fullname: return this.get('first_name') + ' ' + this.get('last_name');
});
return {
User: User
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment