"controller:edit-category.tabs" 模型上的 Observer 未触发

我查看了你的链接,控制器已移至 /admin: discourse/app/assets/javascripts/admin/addon/controllers/edit-category/tabs.js at main · discourse/discourse · GitHub

我不确定为什么它没有触发。也许 @observesmodifyClass 中效果不佳?

作为替代方案,你觉得下面这个怎么样:

@action
saveCategory(data) {
  const oldParentId = this.model.parent_category_id;
  super.saveCategory(data);
  const newParentId = this.model.parent_category_id;

  if (oldParentId !== newParentId) {
    console.log("当父类别更改时在此处应用一些逻辑");
  }
}
3 个赞