javascript - How Do I Update A Button's Text in Meteor's Leaderboard Example? -
I'm totally new to the meteor, and I was doing this. I have a little problem with my code.
I was trying to add a toggle button to toggle the sorting. Toggleing and all are working fine, but the button text does not get updated.
My Javascript code:
if (Meteor.isClient) {Meteor.startup (function () {session .set ("Sort Math", "Score"); }); ... Template.leaderboard.players = function () {if (session. Angle ("sort mode", "name")) player return. ({}, {Sort: {name: 1}}); Otherwise if (session "angle" ("sort mode", "score")) players return. ({}, {Sort: {Score: 1}}); }; ... Template.leaderboard.sortMethod = function () {return Session.get ("sortMethod"); } ... Template.leaderboard.events ({click on 'input.sortToggle': function () {session .equals ("sortMethod", "name")? Session .set ("sort mode", "score") : Season Set ("Sort Methi", "Name");}}); } My Handler Template:
& lt; Template Name = "Leaderboard" & gt; & Lt ;! - This is where it is wrong, Button Text {{sortMethod}} - & gt; Not updated on & lt; Input type = "button" class = "sortToggle" value = "sort {{sortMethod}}" & gt; & Lt ;! - - & gt; & Lt; Div class = "leaderboard" & gt; {{#each player}} {{& gt; Player}} {{/ every}} & lt; / Div & gt; {{#if select_name}} & lt; Div class = "description" & gt; & Lt; Div class = "name" & gt; {{Selected_name}} & lt; / Div & gt; & Lt; Input type = "button" square = "inc" value = "give some point" /> & Lt; / Div & gt; {{Else}} & lt; Div class = "none" & gt; Select & lt; / Div & gt; {{/ If}} & lt; / Template & gt; Note: I deleted some irrelevant code.
This works if you use a button instead:
& gt; Class class = "sortToggle" & gt; Sort {{sortMethod}} & lt; / Button & gt; With this change in events:
Click '.sortToggle': function () {... The input was reported before changing, but it was closed. Maybe it needs to be reopened.
Comments
Post a Comment