jquery widget.bridge bug
jquery bug encountered in 1.9.1
by Avinash_R
HTML
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<div id="test">not created</div>
JavaScript
$(function() {
function MyPlugin(options, element) {
// something good done here!!!
console.log("i'm created here");
this.element = $(element);
this.element.text('created');
}
MyPlugin.prototype = {
loadContent: function(content) {
// parses the content.
console.log("i'm called here");
this.element.text(content).attr('changed after init!!!');
}
};
$.widget.bridge('myPlugin', MyPlugin);
}).call(this, jQuery);
$(function() {
var test = $("#test");
// just delaying it to show the previous content.
setTimeout(function() {
test.myPlugin();
setTimeout(function() {
test.myPlugin('loadContent', '~~~It works!!!~~~');
}, 1000);
}, 1000);
});