在 Plone 5 的分面视图中使用模型模式

Using mockup-patterns in faceted-views in Plone 5

当我在 faceted:view(eea.facetednavigation 的自定义视图)中使用类似 <span class="pat-moment">2016-07-30T15:10:00</span> 的模型模式时,该模式根本不起作用,因为内容是用 javascript.

在 @ebrehault 中写道,模式在加载时初始化,如果 DOM 更改并包含新元素,您需要调用 Registry.scan($('#content-core')),其中 Registrypat-registry#content-core 页面的注入部分。

如何在 eea.facetednavigation (https://github.com/eea/eea.facetednavigation)? It uses a event-system (see https://github.com/eea/eea.facetednavigation/blob/master/eea/facetednavigation/browser/javascript/view.js) 的上下文中执行此操作。我如何收听这些事件之一,我需要哪一个,然后如何调用扫描?

您需要绑定到 eea 的 AJAX_QUERY_SUCCESS 事件:

$(Faceted.Events).bind(Faceted.Events.AJAX_QUERY_SUCCESS, function() {
        Registry.scan($('#content-core'));
});

注意:当你说:

and #content-core the injected part of the page.

那不准确,它不是特定的注入目标(顺便说一下,当您使用模式时并不总是注入,在您的情况下,注入是由 eea.faceted 管理的,这不是模式).您可以重新扫描 DOM 的任何部分,您只需要确保您重新扫描的部分包含您要激活的模式(例如 body 就可以了)。

对于 Plone 5:我在我的插件的 registry.xml 中将下面的代码片段注册为资源,并将其包含在我的 [=13] 的 bundle 插件中=]registry.xml 并使用 ./bin/plone-compile-resources 脚本重建我的插件包。

define([
    'pat-registry'
], function(Registry) {
  'use strict';
    $(Faceted.Events).bind(Faceted.Events.AJAX_QUERY_SUCCESS, function() {
      Registry.scan($('#content-core'));
    });
});