Up until recently, I had been using Safari 4 for testing and debugging my current jQuery Plugin. I tried my code out in Firefox and it started to complain about something within the JQuery-Framework: "setting a property that has only a getter". I tried to find out which line causes Firefox to complain and found that this happens somewhere here**
$.fn.util.create_$dom = function(opt) {
var $dom = {};
$.each(opt.dom,function(name,val){
console.log(name);
var $elm = $('<div>');
$.each(opt.dom[name],function(_name,_val){
if(_name == 'tagName') $elm = $('<'+_val+'/>');
});
console.log(name+': ok');
$.each(opt.dom[name],function(_name,_val){ **here
switch(_name){ **here
case 'className': $elm.addClass(_val); **here
default: $elm.attr(_name, _val); **here
} **here
});
$dom[name] = $elm;
console.log(name+': ok');
});
return $dom;
};
options.dom looks like this:
dom:{
wrapper:{className:'wrapper'},
inner:{tagName:'p',className:'test',test:'bla'}
},
It looks like your trying to set the tagName of an element with this line
$elm.attr(_name, _val);
This of course is not possible as it is read only.
case 'tagName': break;
... is the solution, but in order to thank redsquare for the hint i marked him up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With