core-selected is fired twice per selection change, once after the
previously selected item was deselected and once after the item is
selected. In the deselectione event selectedItem is null. You should look
at event.details and check if this is a selection or deselection event, or
check selectedItem for null.

On Tue, Nov 18, 2014 at 10:41 AM, <[email protected]> wrote:

> Hello,
>
> I am trying to use polymer core menu. Below is my code.On change of menu,
> i am trying log the selected menu.Though it is showing in the log selected
> item but it is throwing error as "Uncaught TypeError: Cannot read property
> 'id' of undefined " after the first selection.I am not sure where i am
> going wrong.Need help...
>
> <polymer-element name="yo-menus" attributes="">
>   <template>
>     <link rel="stylesheet" href="yo-menus.css">
> <section id="midas_menus">
>   <core-ajax auto
>                url="menus.json"
>                response="{{menus}}"
>                handleas="json">
>     </core-ajax>
>  <template if="{{menus}}">
>
> <paper-menu-button>
>         <paper-icon-button icon="menu" noink></paper-icon-button>
>
>           <core-menu class="menu" selected="0"
> selectedItem="{{selectedMenu}}"  valueattr='id'
> on-core-select="{{mainMenu}}">
>             <template repeat="{{menu in menus}}">
>               <paper-item id="{{menu.name}}" label="{{menu.name}}"
> ></paper-item>
>             </template>
>           </core-menu>
>
>       </paper-menu-button>
>
>     </template>
>   </template>
>   </section>
>   <script>
>   Polymer('yo-menus', {
>       // initialize the element's model
>       ready: function() {
>
>       },
>   mainMenu : function(){
>    console.log("New item selected: " + this.selectedMenu.id);
>   }
>
>     });
>   </script>
> </polymer-element>
>
>
> Regards,
> Mausumi
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/f0562018-a0d9-468c-9f3b-62701e1761f7%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/f0562018-a0d9-468c-9f3b-62701e1761f7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CAHk1xZJcBRaYT%2B0tcBbc7B-XdfiGVk8%2BVg2fZGEFB_g1bF2bVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to