Skip to content

Instantly share code, notes, and snippets.

@mikowals
Last active August 29, 2015 13:57
Show Gist options
  • Save mikowals/9716066 to your computer and use it in GitHub Desktop.
Save mikowals/9716066 to your computer and use it in GitHub Desktop.
data-loading-text vs Session
Reproduction of problem getting Bootstrap / JQuery to work with Meteor reactivity
using Meteor 0.8.0-rc0
meteor add bootstrap
Button text stops changing between 'action1' and 'action2' after it has been clicked and had $().button('loading') called.
<head>
<title>uiTest</title>
</head>
<body>
{{> main}}
</body>
<template name="main">
<h1>Hello World!</h1>
<form>
<button type="submit" id="submit" data-loading-text="working...">{{buttonText}}</button>
</form>
<button type="button" id="actionChange">Change Button Text</button>
</template>
if (Meteor.isClient) {
Session.setDefault("action1", "true");
Template.main.buttonText = function () {
return Session.equals( "action1", true) ? "action1" : "action2";
};
Template.main.events({
'submit': function (e) {
e.preventDefault();
$( '#submit' ).button('loading');
if (typeof console !== 'undefined')
console.log("You pressed the button");
Meteor.setTimeout( function(){
$( '#submit' ).button('reset');
}, 1000);
return false;
},
'click #actionChange': function( e ){
Session.set( "action1", Session.equals( "action1", false ));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment