I have an event handler attached to checkboxes. I use the bootstrap switch http://www.bootstrap-switch.org/
I am trying to get a state value that is either true or false in a variable, so I can set its session value.
I can get a true or false value when a state changes (as shown in the rendered code). However, I would like to get this value as part of the events. Check out my variable x.
client.js
Template.myTemplate.rendered = function () { $('input[name="questions"]').bootstrapSwitch('state', true, true); $('input[name="questions"]').on('switchChange.bootstrapSwitch', function(event, state) { console.log(state);
HTML:
<template name="myTemplate"> <div class="row"> <input type="checkbox" name="questions" unchecked> Hobby? </div> <div class="row"> <input type="checkbox" name="questions" unchecked> Writer? </div>
I am trying to get the value that is being printed in console.log(state) inside the rendered code into a variable inside my event, so I can set the session value to both true and false.
Template.myTemplate.events({ 'click input': function(event) { var x = $(this).is(":checked").val(); Session.set("statevalue", x); console.log(Session.get("statevalue"));
source share