Reputation: 11
I'm experimenting with some old code for a shopping cart that I've discovered online, to try to get it working with version 0.8 (I know 0.9 and 1.0 are available, but that comes later...!)
I've managed to update all except one line of code:
<span class="cart-list__item-discard discard-from-cart fa fa-lg fa-trash" on-click="discard:{{i}}"></span>
It's returning this message:
Proxy events with arguments are deprecated. You can fire events with arguments using "@this.fire('eventName', arg1, arg2, ...)". at line 14 character 105:
<span class="cart-list__item-discard discard-from-cart fa fa-lg fa-trash" on-click="discard:{{i}}"></span>
I've tried different changes to the code, such as removing the :{{i}}
and rewriting it to use @this.fire
as suggested, but the former removes the wrong item, and the latter results in no action! Clearly I'm missing something here. How should I rewrite this line of code to work with Ractive 0.8 and remove the deprecation warning?
Upvotes: 1
Views: 73
Reputation: 119847
on-*
supports three forms of syntax
The proxy syntax (event name only, no arguments)
<button type="button" on-click="eventname">Push me!</button>
And the expression syntax (expression value)
<button type="button" on-click="@this.method('Hello, World!')">Push me!</button>
The third is a special form of the expression syntax where it's an array whose first value is the event name and the rest are its arguments. This one closely resembles the old proxy syntax with args.
<button type="button" on-click="['eventname', 'Hello, World!']">Push me!</button>
More on on-*
in the documentation.
Upvotes: 1