jQuery UI Draggable w/ Custom UI Widget
HTML
<script src="http://code.jquery.com/ui/1.8.23/jquery-ui.js"></script>
<div id="test">
ABC
</div>
<br>
<div id="test1">
DEF
</div>
JavaScript
(function ($)
{
$.widget("custom.alonso",
{
message : {
value: "abc"
},
setMessage: function(message) {
this.message = message;
},
showMessage : function() {
console.log(this.message);
}
});
}
)(jQuery);
$(document).ready(function() {
$("#test").alonso();
$("#test").click(function() {
$("#test").alonso("setMessage","phong tran");
$("#test").alonso("showMessage");
$("#test1").alonso();
})
$("#test1").click(function() {
$("#test1").alonso("showMessage");
})
});