-
Notifications
You must be signed in to change notification settings - Fork 643
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
Allow on-* attribute to bind additional arguments #401
Comments
As an implementation detail, we want to avoid serializing the extra arguments to a JSON stringify in the browser. On the server we have no choice but to |
I've been giving this issue some more thought and am capturing some of my thoughts/notes below for discussion: Currently, marko associates a DOM event with a handler method on a particular widget by rendering out a special <div data-w-onevent="method_name|widget_id"> For example: <div data-w-onclick="handleButtonClick|w0-myButton|<arg1"> Now, with this change need to associate additional arguments with the event handler. For example: <div data-w-onclick="handleButtonClick|w0-myButton|arg1|arg2|arg3"> What I am thinking is that in v4 we can make some changes to support providing a complex object with an attribute. For example: <div data-w-onclick={method: 'handleButtonClick', widgetId: 'w0', args: [ 'foo', 'bar' ] }> Currently, this renders as the following since we call <div data-w-onclick="[object Object]"></div> We could choose to <div data-w-onclick='{"method":"handleButtonClick","widgetId":"w0","args":["foo","bar"]}'> If rendered in the browser, there is likely no reason to var eventInfo = require('marko').getObjectAttribute(el, 'data-w-onclick');
console.log(eventInfo.method); That's all for now. |
As mentioned in #394, we are moving from
w-on-click="method"
toon-click('method')
as the way to delegate events within a template.We also want to allow you to bind additional arguments:
Bound arguments will be prepended to the argument list much like a function bind in js:
The text was updated successfully, but these errors were encountered: