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 passing arguments to methods #76

Open
jkroso opened this issue Jul 10, 2013 · 2 comments
Open

support passing arguments to methods #76

jkroso opened this issue Jul 10, 2013 · 2 comments

Comments

@jkroso
Copy link

jkroso commented Jul 10, 2013

e.g:

<div>{render(items)}</div>

This almost works already but is just a little broken since it gets transformed to

'<div>' + model.render(call(model, view, 'items')) + '</div>'

where's what I wanted was to call the view's render method.

The use case is to make it easier to jump back to JS when you need the power. Though it could be used in place of computed properties in some cases.

@cristiandouce
Copy link
Member

This would also be nice combined with what I just described on a comment at #140
link to comment

That way at a on-click binding you wouldn't have to query the DOM to get some data-something saved. You just could on-click="select(name)" and then

View.prototype.select = function (ev, name) { // ev should always be passed first IMO
   this.view.set('current', name)
}

No need for var name = dom(ev.target).getAttribute('data-name')...

@defunctzombie
Copy link
Contributor

The issue with passing arguments to events is dealing with iteration. Currently, the second argument to an event handler is the reactive instance for the iterated item. This allows for implementing lists with delete buttons and access to the iterated instance. Maybe looking at home some other libs are handling this could provide some insight.

I think the original posted issue could be made to work tho and will see if that is the case without too much pain.

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

3 participants