[ckan-dev] Can we add a data-module into a template loaded from ajax_snippets

Vitor Baptista vitor at vitorbaptista.com
Sun Jun 8 02:45:26 UTC 2014


Hi Qifeng,

The modules are initialized at
https://github.com/ckan/ckan/blob/master/ckan/public/base/javascript/main.js#L36
, which happens as soon as main.js is loaded on the page. Any module
defined after that won't be initialized.

If you really need it, you could call ckan.initialize() after loading any
other modules on your page, but I'd rather avoid it. I'm not sure what
consequences it'll have.

Cheers,


2014-06-04 2:49 GMT-03:00 <Qifeng.Bai at csiro.au>:

>  Hi, there
>
>
>
> I have a javascript data-module which reads a template file in
> ajax_snippets and show it on the page.  It works well.
>
>
>
> In this template file, I try to call another data-module. It seems this
> data-module is not fired at all.
>
>
>
> For example, I defined a template file called ‘test.html’ under
> ajax_snippets:
>
> In test.html, I wrote “<div data-module=’init_test’></div>”
>
>
>
> This module does nothing, just print out some info:
>
> ckan.module(’init_test’, function ($, _) {
>
>   return {
>
>     initialize: function () {
>
>       $.proxyAll(this, /_on/);
>
>       Consol.log(‘I am inited’);
>
>   },
>
> ………………
>
>
>
> And then in an outside data-module, I called :
>
>
>
> this.sandbox.client.getTemplate(test.html’, this._onReceiveTemplate);
>
> ……………………………………..
>
>
>
> I found after the test.html was shown on the page, but there was no any
> console outputs.
>
>
>
> Is that meant to be?
>
>
>
> Cheers
>
>
>
>
>
>
>
> [image: cid:image001.gif at 01CC55BF.85E7FEB0]
>
> Qifeng Bai
> Software Engineer
> CSIRO Land and Water
> Black Mountain, Canberra
>
> Ph: +61-2-62465704
> Web: www.clw.csiro.au
>
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>


-- 

Vítor Baptista

Developer  |  http://vitorbaptista.com | LinkedIn
<http://www.linkedin.com/in/vitorbaptista> | @vitorbaptista
<http://twitter.com/vitorbaptista>

The Open Knowledge Foundation <http://okfn.org>

*Empowering through Open Knowledge*

http://okfn.org/  |  @okfn <http://twitter.com/okfn>  |  OKF on Facebook
<https://www.facebook.com/OKFNetwork>  |  Blog <http://blog.okfn.org/>  |
Newsletter <http://okfn.org/about/newsletter/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140607/b86ae921/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 2094 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140607/b86ae921/attachment-0003.gif>


More information about the ckan-dev mailing list