0

I am trying to remove an element from a list that is being displayed with a {^{for}} loop by clicking an <i> element. This could of course be achieved through jQuery's .on as seen here: Todos example, Source Line 138

But I would like a jQuery-free approach or at least less binding. So I checked if the (e.g.) onclick would help with the following:

<i onclick="console.dir(this);">delete</i>

But I found nothing helpful in the console.

Is there a way to retrieve jsViews compatible data from within the onclick?
And if not: Is there a way to bind a helper or something to a DOM event? I'm imagining something like:

<i onclick=~deleteItem>delete</i>
neo post modern
  • 2,262
  • 18
  • 30
  • I now use `delete` - it requires no jQuery or other binding. [The object has a `Delete` method that does a server call.] Binding a helper to a DOM event still would be a nice feature. – neo post modern Oct 08 '13 at 10:25
  • 1
    You can now do delete to call a helper, or delete to call a data method. update, for example, lets you choose the trigger. – BorisMoore Jan 22 '14 at 05:39

1 Answers1

1

Yes, that's right, you use $.view(this) (where this is the HTML element instance) to get the view, and from there you can get the data, and a lot more.

You might be interested in this new 'tutorial sequence' - http://www.jsviews.com/#samples/data-link - and especially this page http://www.jsviews.com/#samples/data-link/hover - which relates to different ways of hooking up to DOM events.

BorisMoore
  • 8,444
  • 1
  • 16
  • 27