Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-64061

Ability to call js_call_amd() to just load an AMD module without calling its function

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.3
    • Fix Version/s: 3.7
    • Component/s: JavaScript
    • Labels:

      Description

      When integrating an external JS library into a plugin, it is not always straightforward to load it easily, even if the library supports loading via AMD/UMD. The thing is that js_call_amd() insists on having a module's function to call. But not all module need an explicit initialization/booting call to start. It is enough to load the module and it itself does its job (typically finds all the elements with the appropriate data-* attributes, and does its thing with them). An example of such a library is https://github.com/lokesh/lightbox2/blob/dev/dist/js/lightbox.js

      We discussed this (https://moodle.org/local/chatlogs/index.php?conversationid=22752) and concluded it would be nice to have the function name optional, in which case the js_call_amd() would simply just load the module.

        Attachments

          Activity

            People

            Assignee:
            mudrd8mz David Mudrák (@mudrd8mz)
            Reporter:
            mudrd8mz David Mudrák (@mudrd8mz)
            Peer reviewer:
            Tim Hunt
            Integrator:
            Andrew Nicols
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              20/May/19