javascript - How to obtain innerHTML of an active li link? -
i want store innerhtml of active menu item display title page. title html {{pagetitle}}, in "container" template.
here (cleaned) html
<template name="container"> {{pagetitle} {{ > sidemenu}} </template> <template name="sidemenu"> <ul id="menu-items" class="nav nav-stacked nav-pills"> <li id="menu-item-simple" class=""> <a href="#"> menuitem1 </a> </li> <li id="menu-item-simple" class=""> <a href="#"> menuitem2 </a> </li> </ul> </template>
i created helper return string
template.container.helpers({ "pagetitle":function(){ return session.get("pagetitle"); } });
and event set string correct value when menu item clicked
template.sidemenu.events({ "click #menu-items":function(e,t){ var activeitem = $(this).find("li.active") session.set ("pagetitle",activeitem.children("a").innerhtml); console.log (activeitem.children("a").innerhtml); } });
the console returns "undefined". don't doing wrong , since i'm beginning, wanted know if i'm going right way.
Comments
Post a Comment