Hi,
I'm struggling to find my way around the various types of JS in Moodle; I have a load of data (including user HTML) to load into my AMD module - but MDL-49046 says I shouldn't pass massive amounts of data or huge rendered blocks of escaped HTML to the javascript via js_call_amd().
A previous solution for M2.0 points towardsusing data_for_js(), which has since been deprecated in favour of js_init_call() - but I don't see how to use that with AMD
What am I missing?
Edit: After re-reading js_call_amd() guide: "A preferred approach is to pass css selectors for DOM elements that contain data-attributes for any required data, or fetch data via ajax in the background."
- I guess I could dump JSON into a hidden element, load it and parse it - seems pretty clunky
- I don't want to fetch data via ajax in the background, as it will create more requests and slow the page load.
Cheers,
Dave.