Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(app){
- app.Views.MainView = Backbone.View.extend({
- el:'html',
- events:{
- 'click .clickAddPupil':'showFormPupil',
- 'click .addFormPupil':'addPupil',
- 'change input':'validate'
- },
- initialize:function(){
- this.listenTo(this.collection, 'add', this.render);
- },
- render:function(){
- var PupilView = new app.Views.PupilView({
- model:this.model
- });
- this.$('ul').append(PupilView.render().el);
- },
- showFormPupil:function(){
- $('form').removeClass();
- },
- validate:function(elem){
- if(elem.val()==0){
- console.log('vcdv')
- }
- },
- addPupil:function() {
- this.$('form').submit(function(){return false});
- var dataObject = {
- name: this.$('.name').val(),
- surname: this.$('.surname').val(),
- mathematics: this.$('.mathematics').val(),
- english: this.$('.english').val(),
- ukrainian: this.$('.ukrainian').val(),
- history: this.$('.history').val()
- };
- this.model = new app.Models.PupilModel();
- this.model.set(dataObject);
- this.collection.add(this.model);
- this.$('form').addClass('none');
- },
- })
- }(window.application));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement