Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events in the view #40

Open
Veid opened this issue Jul 31, 2013 · 1 comment
Open

Events in the view #40

Veid opened this issue Jul 31, 2013 · 1 comment

Comments

@Veid
Copy link

Veid commented Jul 31, 2013

The example in the readme about events in the view doesn't seem to work, as the alert never shows:

var view = new Backbone.View({
    initialize: function () {
        this.bind("ok", okClicked);
    },

    okClicked: function (modal) {
        alert("Ok was clicked");
        modal.preventClose();
    }
});

var modal = new Backbone.BootstrapModal({ content: view }).open();

This is the related code in backbone.bootstrap-modal.js:

'click .ok': function(event) {
  event.preventDefault();
  this.trigger('ok');

  if (this.options.content && this.options.content.trigger) {
    console.log("Content:", this.options.content);
    console.log("Modal  :", this);
    this.options.content.trigger('ok', this);
  }

  if (this.options.okCloses) {
    this.close();
  }
}

I'm rather new to Backbone so I don't fully get what's happening with the context when this.options.content.trigger('ok', this) is called.

If someone could explain this to me and nudge me in the right direction to get the above example working, that would be great!

Thanks!

@acrawly
Copy link

acrawly commented Dec 1, 2015

+1 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants