var STICKIES = (function () {
/* some code here*/
createSticky = function createSticky(data) {
$('#color-picker'+data.id).ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
// TODO: Call saveSticky from here
return false;
},
onChange: function (hsb, hex, rgb) {
$('#'+data.id).css('background-color', '#' + hex);
colorInHex = hex;
}
});
},
saveSticky = function saveSticky() {
var that = $(this),
sticky = (that.hasClass("color-pick") || that.hasClass("sticky-status") || that.hasClass("sticky-content") || that.hasClass("sticky-status-time")) ? that.parents('div.sticky'): that,
obj = {
id : sticky.attr("id"),
top : sticky.css("top"),
left: sticky.css("left"),
text: sticky.children(".sticky-content").text(),
createdDate: sticky.find(".sticky-status-time").text(),
colorOfNote: rgb2hex(sticky.css("background-color")) }
localStorage.setItem("sticky-" + obj.id, JSON.stringify(obj));
sticky.find(".sticky-status").css('color','grey').text("saved");
chkForNoNote();
},
/* some code here*/
return {
open : openStickies,
init : initStickies,
"new" : createSticky,
remove : deleteSticky
};
}());
//我正在尝试在创建便利贴纸时保存颜色。为此,在函数onHide()中,我需要调用saveSticky().
saveSticky()
碰巧是STICKIES的函数,ColorPicker()
是colorPicker的函数。我怎么称之为saveSticky?
答案 0 :(得分:0)
您需要致电:
STICKIES.saveSticky.call(mySticky);
其中mySticky
是对您要保存的任何粘性对象的引用。