[Total Newbie] getting dataset value

42 views
Skip to first unread message

Yvon Thoraval

unread,
Dec 2, 2014, 1:56:32 AM12/2/14
to polym...@googlegroups.com
in my template,i have :
<li data-_id="{{category._id}" on-click="{{selectCategory}}">...

in js :
Polymer('my-categories', {
  ready: function() {
    this.categories = [
      {_id: 1, name: 'Abonnements'}
      , {_id: 2, name: 'Clés de logiciels'}
      , {_id: 3, name: 'Formulaires'}
      , {_id: 4, name: 'Groupes de nouvelles'}
      , {_id: 5, name: 'Références'}
    ];
  },     
  selectCategory: function(e) {
    this.selectedCategoryId = e.target.dataset._id;
    console.log("this.selectedCategoryId = " + this.selectedCategoryId);
    // => this.selectedCategoryId = {{category._id}
  }
});


when i click to one element i get :
this.selectedCategoryId = {{category._id}
insted of a number in 1..5, why?

Rob Dodson

unread,
Dec 3, 2014, 7:08:12 PM12/3/14
to Yvon Thoraval, polymer-dev
You're missing a curly brace in your binding:

<li data-_id="{{category._id}" on-click="{{selectCategory}}">...

should be

<li data-_id="{{category._id}}" on-click="{{selectCategory}}">...

here's a working example: http://jsbin.com/gexoxi/3/edit

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/b05c3bf4-3408-4030-a25f-66f12bd38156%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yvon Thoraval

unread,
Dec 3, 2014, 9:37:51 PM12/3/14
to Rob Dodson, polymer-dev
Fine, tanx, i didn't catch that "}"...
--
Yvon@48.871651804,2.384858688

Reply all
Reply to author
Forward
0 new messages