Skip to content

Instantly share code, notes, and snippets.

@SeonghoonKim
Created September 4, 2012 04:26
Show Gist options
  • Select an option

  • Save SeonghoonKim/3616578 to your computer and use it in GitHub Desktop.

Select an option

Save SeonghoonKim/3616578 to your computer and use it in GitHub Desktop.

Revisions

  1. SeonghoonKim created this gist Sep 4, 2012.
    26 changes: 26 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    var XyzView = Marionette.ItemView.extend({
    template : '#xyz-tpl',

    ui : {
    form : 'form'
    },

    events : {
    'click button.action' : 'onActionRequested',
    'submit' : 'onActionRequested'
    },

    onRender : function() {
    this.ui.form.validate();
    },

    onActionRequested : function(event) {
    event.preventDefault();

    if (!this.ui.form.valid()) {
    this.ui.form.validate().focusInvalid();
    return false;
    }
    // ...
    }
    });