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

Support for namespaced events #366

Closed
defunkt opened this issue May 24, 2011 · 2 comments
Closed

Support for namespaced events #366

defunkt opened this issue May 24, 2011 · 2 comments

Comments

@defunkt
Copy link

defunkt commented May 24, 2011

Right now it looks like a Backbone.View doesn't support binding namespaced events to this.el because of the eventSplitter regexp: /^(\w+)\s*(.*)$/

For example, I want to bind my view to end.pjax:

class MyView extends Backbone.View
  events:
    'end.pjax': 'hideLoader'

  hideLoader: ->
    this.$('.context-loader').hide()

The above won't work because the regexp splits up end and pjax:

> "end.pjax".match(/^(\w+)\s*(.*)$/)
[ 'end.pjax', 'end', '.pjax', index: 0, input: 'end.pjax' ]

Is this a bug, or is there a reason dots aren't allowed in that regexp? Or am I just doing it wrong.

@defunkt
Copy link
Author

defunkt commented May 24, 2011

Patch if this is unintentional: https://github.com/defunkt/backbone/commit/patch-1

@jashkenas
Copy link
Owner

As discussed over on the other commit -- there's a patch + test. Closing the ticket.

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

No branches or pull requests

2 participants