Last active
August 29, 2015 14:01
-
-
Save pipiscrew/0f9c32268f95f4543447 to your computer and use it in GitHub Desktop.
[js] Firebase - Transaction update multiple fields
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> | |
<script type='text/javascript' src='jquery-1.10.2.min.js'></script> | |
<!-- firebase --> | |
<script type='text/javascript' src='https://cdn.firebase.com/v0/firebase.js'></script> | |
<script type='text/javascript' src='https://cdn.firebase.com/v0/firebase-simple-login.js'></script> | |
<script type="text/javascript"> | |
$(function() { | |
$('#btn').on('click', function(e) { | |
var db = new Firebase('https://x.firebaseio.com/mynode/-JFXdllZKp2AE9uJOZlN/stats'); | |
db.transaction(function(rec) { | |
// If test1 or test2 has never been set, will be setted! | |
if (rec!=null){ | |
rec["test1"]="pipiscrew"; | |
rec["test2"]=1; | |
} | |
return rec; | |
}, function(error, committed, snapshot) { | |
if (committed){ | |
mae2(cause_id,3); | |
} | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<button id="btn">Push Me</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment