Mam problem.. zdefiniowałem obiekt:
<script type="text/javascript">
var ppp = {
_likedata:{id:0,url:""},
constructor : function(){
this.__defineGetter__("likedata", function(){
return this._likedata;
}),
this.__defineSetter__("likedata", function(val){
this._likedata = val;
})
},
getLikeData : function() {
if(this.getlikeid()!=0){
this.getData('likes', '{"id" : "' + this.getlikeid() + '"}');
}
else{
this.getData('likes', '');
}
},
setlikeurl:function(url){
this._likedata.url=url;
},
setlikeid:function(id){
this._likedata.id=id;
},
getlikeid:function(){
return this._likedata.id;
},
getlikeurl:function(){
return this._likedata.url;
},
renderLike: function() {
this.getLikeData();
$('#likes').html('<fb:like href="' + this.getlikeurl() + '" layout="button_count" show_faces="false" width="65" action="like" font="segoe ui" colorscheme="light" />');
if (typeof FB != "undefined") {
FB.XFBML.parse(document.getElementById('like'));
}
},
getData : function (ltype, sendJson) {
var like;
$.ajax({
type: "POST",
url:"/get-Points/" + ltype,
data: sendJson,
dataType:"json",
beforeSend: function(x) {
if (x && x.overrideMimeType) {
x.overrideMimeType("application/json;charset=UTF-8");
}
},
error: function(data) {
//em
},
success: function(data) {
if (data.systemError != undefined) {
window.location.href = "/auth/login";
}
if (data.likeError != undefined) {
$('#' + ltype).html('
<p>' + data.likeError + '
</p>');
jQuery.extendedjsoncookie("removeCookie", "g" + ltype);
}
else {
this.setlikeid(data.id);
this.setlikeurl(data.url);
//this._likedata.id=data.id;
//this._likedata.url=data.url;
// this.likedata=data;
// jQuery.extendedjsoncookie( "setCookieVariable","g"+ltype+i, "url", data.buttonsData.url);
// jQuery.extendedjsoncookie( "setCookieVariable","g"+ltype+i, "id", data.buttonsData.id);
}
}
});
}
}
Problem jest taki, że firebug mówi:
- jeśli nie używam getterów/setterów że _likedata nie istnieje
- jeśli ich używam- wg firefoxa nie są funkcjami.. tzn uruchamiając w konsoli ppp.setlikeurl("costam") dziala ale w kodzie this.setlikeurl("cosinnego") juz nie.
Łysięję już i mam dość. Pomocy.
Ten post edytował marki 9.10.2011, 12:42:38