Browse Source

Fix duplicated init for widgets.

pull/5569/head
Halil İbrahim Kalkan 6 years ago
parent
commit
c65b160422
  1. 28
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js
  2. 2
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs

28
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js

@ -52,8 +52,12 @@
}
function init($widgets) {
if(!$widgets){
$widgets = opts.wrapper.findWithSelf('.abp-widget-wrapper');
if (!$widgets) {
if (opts.wrapper.hasClass('abp-widget-wrapper')) {
$widgets = opts.wrapper;
} else {
$widgets = opts.wrapper.find('.abp-widget-wrapper');
}
}
$widgets.each(function () {
@ -72,8 +76,12 @@
}
function refresh($widgets) {
if(!$widgets){
$widgets = opts.wrapper.findWithSelf('.abp-widget-wrapper');
if (!$widgets) {
if (opts.wrapper.hasClass('abp-widget-wrapper')) {
$widgets = opts.wrapper;
} else {
$widgets = opts.wrapper.findWithSelf('.abp-widget-wrapper');
}
}
$widgets.each(function () {
@ -90,7 +98,9 @@
}).then(function (result) {
var $result = $(result);
$widget.replaceWith($result);
init($result);
if($widget.attr('data-widget-auto-init') !== "true"){
init($result);
}
});
} else {
var widgetApi = $widget.data('abp-widget-api');
@ -115,9 +125,9 @@
return publicApi;
};
function autoInitWidgets($wrapper){
function autoInitWidgets($wrapper) {
$wrapper.findWithSelf('.abp-widget-wrapper[data-widget-auto-init="true"]')
.each(function(){
.each(function () {
var widgetManager = new abp.WidgetManager({
wrapper: $(this),
});
@ -126,11 +136,11 @@
});
}
abp.dom.onNodeAdded(function(args){
abp.dom.onNodeAdded(function (args) {
autoInitWidgets(args.$el);
})
$(function(){
$(function () {
autoInitWidgets($('body'));
});

2
modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs

@ -83,6 +83,8 @@ namespace Volo.CmsKit
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}framework/src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar)));

Loading…
Cancel
Save