Last active
August 29, 2015 13:57
-
-
Save mikowals/9716066 to your computer and use it in GitHub Desktop.
data-loading-text vs Session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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