Parse.com和JavaScript SDK。
当我运行以下代码时,捕获的用户名看起来像旧的已删除用户,因此指针未正确创建。但是,当我从jfiddle运行它时,会捕获正确的用户名。
我尝试删除文件,转储缓存等。
我不明白为什么/谁引用旧用户以及如何阻止这种情况发生?
我绝对是以合适的用户身份登录的。
我唯一可以解决的问题是它在主代码的子文件夹中,可能因为这个而没有捕获用户名吗?
<script type="text/javascript">
Parse.initialize("xxx", "xxx");
var MyBadges = Parse.Object.extend("myBadges");
var userbadges = new MyBadges();
var currentUser = Parse.User.current();
$(document).ready(function () {
$("#send").click(function () {
var badgeselected = $('#badgeselect .go').attr("src");
userbadges.set("BadgeName", badgeselected);
//userbadges.set("username", user);
userbadges.set("username", currentUser);
console.log("done");
console.log(currentUser);
userbadges.save(null, {
success: function (results) {
// The object was saved successfully.
console.log(currentUser);
//location.reload();
},
error: function (contact, error) {
// The save failed.
// error is a Parse.Error with an error code and description.
alert("Error: " + error.code + " " + error.message);
}
});
});
});
$(document).ready(function () {
$('.go').css('cursor', 'pointer');
$('.go').click(function (e) { // Button which will activate our modal
$(this).width(100).height(100).appendTo('#badgeselect');
$('#modal').reveal({ // The item which will be opened with reveal
animation: 'fade', // fade, fadeAndPop, none
animationspeed: 600, // how fast animtions are
closeonbackgroundclick: true, // if you click background will modal close?
dismissmodalclass: 'close' // the class of a button or element that will close an open modal
});
return false;
});
});
</script>
答案 0 :(得分:0)
我通过删除myBadges类并重建它来解决这个问题。