resource.config命令和自定义渲染错误没有按预期工作

时间:2016-06-08 08:02:56

标签: ckan fanstatic

我尝试使用ckanext_reclineview呈现CSV数据。我在Windows 7上运行ckan2.5.2

我在加载查看器时遇到以下JS错误:

Uncaught ReferenceError: Backbone is not defined
(anonymous function) @ widget.recordcount.js:9
(anonymous function) @ widget.recordcount.js:29

Uncaught TypeError: Cannot read property 'each' of undefined
(anonymous function) @ backbone.js:216
(anonymous function) @ backbone.js:1571

Uncaught TypeError: Cannot read property 'isUndefined' of undefined
(anonymous function) @ ckan.js:214
(anonymous function) @ ckan.js:254

Uncaught TypeError: Cannot read property 'extend' of undefined
(anonymous function) @ recline.js:399
(anonymous function) @ recline.js:1037

Uncaught TypeError: recline.Model.Dataset is not a constructor
loadView @ recline_view.js:59
_onReady @ recline_view.js:27
proxy @ jquery.js:827
fire @ jquery.js:3048
self.add @ jquery.js:3094
jQuery.fn.jQuery.ready @ jquery.js:271
initialize @ recline_view.js:18
module.createInstance @ module.js:320
(anonymous function) @ module.js:289
jQuery.extend.each @ jquery.js:657
module.initializeElement @ module.js:285
(anonymous function) @ module.js:262
jQuery.extend.each @ jquery.js:657
jQuery.fn.jQuery.each @ jquery.js:266
module.initialize @ module.js:261
(anonymous function) @ main.js:47
fire @ jquery.js:3048
self.fireWith @ jquery.js:3160
(anonymous function) @ jquery.js:3211
fire @ jquery.js:3048
self.fireWith @ jquery.js:3160
done @ jquery.js:8235
callback @ jquery.js:8778

我发现Javascript加载的顺序并没有按预期工作。

与其他资源不同,所有recline_view JS文件都是基于JS文件名顺序加载的。 backbone.js依赖于underscore.js,但在underscore.js

之后加载了backbone.js

请参阅下面的生成HTML:

<script type="text/javascript" src="/fanstatic/vendor/:version:2016-06-03T12:33:21.23/jquery.js"></script>
<script type="text/javascript" src="/fanstatic/vendor/:version:2016-06-03T12:33:21.23/jed.js"></script>
<script type="text/javascript" src="/fanstatic/vendor/:version:2016-06-03T12:33:21.23/moment-with-locales.js"></script>
<script type="text/javascript" src="/fanstatic/vendor/:version:2016-06-03T12:33:21.23/select2/select2.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/sandbox.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/module.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/pubsub.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/client.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/notify.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/i18n.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/main.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.date-helpers.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.form-warning.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.inherit.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.masonry.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.proxy-all.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.slug-preview.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.slug.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.truncator.js"></script>
<script type="text/javascript" src="/fanstatic/base/:version:2016-06-06T15:49:43.51/plugins/jquery.url-helpers.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/widget.recordcount.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/recline_view.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/backbone/1.0.0/backbone.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/bootstrap/2.3.2/bootstrap.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/ckan.js/ckan.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/flot/excanvas.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/flot/jquery.flot.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/flot/jquery.flot.time.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/jquery/1.7.1/jquery.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/json/json2.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/leaflet/0.7.3/leaflet.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/leaflet.markercluster/leaflet.markercluster.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/moment/2.0.0/moment.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/mustache/0.5.0-dev/mustache.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/recline/recline.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/slickgrid/2.0.1/jquery-ui-1.8.16.custom.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/slickgrid/2.0.1/jquery.event.drag-2.0.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/slickgrid/2.0.1/slick.grid.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/slickgrid/2.0.1/plugins/slick.rowmovemanager.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/slickgrid/2.0.1/plugins/slick.rowselectionmodel.js"></script>
<script type="text/javascript" src="/fanstatic/ckanext-reclineview/:version:2016-06-08T15:44:54.11/vendor/underscore/1.4.4/underscore.js"></script></body>

这是我的resource.config文件:

[main]

force_top = vendor/underscore/1.4.4/underscore.js   
order = vendor/underscore/1.4.4/underscore.js vendor/backbone/1.0.0/backbone.js

[IE conditional]

lte IE 7 =
    vendor/json/json2.js

lte IE 8 =
    vendor/flot/excanvas.js



[custom render order]

vendor/underscore/1.4.4/underscore.js = 18
vendor/backbone/1.0.0/backbone.js = 19

[depends]

main = base/main

[groups]

main =
    vendor/jquery/1.7.1/jquery.js
    vendor/underscore/1.4.4/underscore.js
    vendor/backbone/1.0.0/backbone.js
    vendor/mustache/0.5.0-dev/mustache.js
    vendor/bootstrap/2.3.2/bootstrap.js
    vendor/json/json2.js
    vendor/flot/excanvas.js
    vendor/flot/jquery.flot.js
    vendor/flot/jquery.flot.time.js
    vendor/leaflet/0.7.3/leaflet.js
    vendor/leaflet.markercluster/leaflet.markercluster.js
    vendor/slickgrid/2.0.1/jquery-ui-1.8.16.custom.js
    vendor/slickgrid/2.0.1/jquery.event.drag-2.0.js
    vendor/slickgrid/2.0.1/slick.grid.js
    vendor/slickgrid/2.0.1/plugins/slick.rowselectionmodel.js
    vendor/slickgrid/2.0.1/plugins/slick.rowmovemanager.js
    vendor/moment/2.0.0/moment.js
    vendor/ckan.js/ckan.js

    vendor/recline/recline.js

    widget.recordcount.js
    recline_view.js

    vendor/bootstrap/2.3.2/css/bootstrap.css
    vendor/leaflet/0.7.3/leaflet.css
    vendor/leaflet.markercluster/MarkerCluster.css
    vendor/leaflet.markercluster/MarkerCluster.Default.css
    vendor/slickgrid/2.0.1/slick.grid.css
    vendor/recline/recline.css

    css/recline.css

任何帮助将不胜感激

由于

1 个答案:

答案 0 :(得分:0)

作为解决方法,我将文件夹vendor/underscore/重命名为vendor/aunderscore/,以便fanstatic优先加载underscore.js backbone.js