我正在创建一个小部件名称为“讨论小部件”。它的 create 函数默认被调用。但是我试图调用的下一个加载函数没有被调用。请帮忙 :
(function ($, undefined) {
$.widget('ui.discussionwidget', {
options: {
userName: 'Arti Agarwal',
title: "",
width: "",
containerClass: ".ui-content-gutter"
},
_create: function () {
// Create the structure of Discussion Widget
var widgetStructure = $('<div class="ui-discussion hGridPx_120 wGridPx_10"></div>');
widgetStructure.appendTo($($(this.options.containerClass)));
},
load: function (datasource) {
//Load the discussion history
debugger;
var ds = datasource;
var message = $.parseJSON(ds.d);
$("#ui-discussion").html(null);
$.each(message, function (index, item) {
if (item.ParentID == "NULL" && item.Display_Text != "") {
var content = "<div><div id='empImage'><img src='" + item.emp_thumbnail_src + "'/></div>" + "<div>" +
"<label id='empName'>" + item.Enterprise_Id + "</label><label id='chatdate'>" + item.Date + "</label>" +
"<label>" + item.Display_Text + "</label><label id='" + item.DiscussionID + "' class='discussionID'>" + item.DiscussionID + "</label></div></div>";
$('<ul><li class="ui-discussion-parentmessage">' + content + '</li></ul>').appendTo('#ui-discussion');
}
$('#replychat').addClass('ui-reply-disabled');
}
});
},
widget: function () {
return this.element;
},
destroy: function () {
$.Widget.prototype.destroy.call(this);
}//extra , here
});
var CloseDiscussionWidget = function () {
}
})(jQuery);
这是页面代码,这里我正在创建小部件并调用讨论小部件控件的方法加载。:
(function ($) {
// Load discussion history fist time
$(document).ready(function () {
Discussionwidget = $('.ui-content-gutter').discussionwidget({
containerClass: ".ui-content-gutter"
});
$.ajax({
type: "POST",
url: baseURL + "/services/peoplewebservice.asmx/GetDiscussionHistory",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
debugger;
($(Discussionwidget)).load(data);
}
});
})
}(jQuery));