Sha256: 4a900735d3e0db2b64af0168dd61a9683aed9a70a2e869a345e3cbc75881340e

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

var FileView = Backbone.View.extend({
    tagName: 'li',
    className: 'span2',
    events: {
        "click .delete": "delete",
        "click .photo-link": "photo_link",
    },
    initialize: function(){
        this.template = JST['photo_view']
        this.model.on('change', this.render, this);
        this.model.on('uploadCompleted', this.removeProgressBar, this);
    },
    removeProgressBar: function(){
        if(this.$el != undefined)
            this.$el.find('.progress').fadeOut();
    },
    render : function(){
        var data = _.defaults(this.model.attributes, {progress: null, id: null, title: null})
        var html = this.template(this.model.attributes);
        $(this.el).html(html);
        return this;
    },
    delete: function(e) {
        e.preventDefault();
        this.model.destroy({
          success: function(model, response){
            console.log("Success");
          },
          error: function(model, response){
            console.log("Error");
          }
        });
        this.$el.fadeOut();
    },
    photo_link: function(e) {
        e.preventDefault();
        Backbone.history.navigate(":photo_id/ajax_edit".replace(':photo_id', this.model.get('id')), {trigger: true});
    }
});

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
mix-rails-0.15.0 mix-rails-albums/app/assets/javascripts/views/fileview.js
mix-rails-albums-0.15.0 app/assets/javascripts/views/fileview.js
mix-rails-0.12.2 mix-rails-albums/app/assets/javascripts/views/fileview.js
mix-rails-albums-0.12.2 app/assets/javascripts/views/fileview.js