Javascript in Course Modules won't load in Modals

Issue #12 new
Justin Hunt created an issue

Hi David.

Great work on the Tiles format, its really nifty and looks great.

The issue one of the Poodll users has is that Poodll widgets on a Page activity do not show up properly in a modal. That is because the AMD javascript code is not being applied to content in the modal. I have encountered this before with some lightboxes, and I am not sure how easy it would be to fix. For now I just instructed them to not show "Page" activities in a Modal.

I just wanted to bring it to your attention.

Comments (3)

  1. David Watson repo owner

    Thanks Justin! That sounds like a good workaround short term.

    Are your AMD modules being initialised? When "Tiles" renders the page modal, it does call core's "format_text()" on the content, via format_tiles_renderer\format_cm_content_text(). I believe that this would initialise your AMD modules, and maybe it does, but obviously we are missing something at some point.

    I wonder if I could do something temporary in tiles, to stop the page being rendered as a modal if the content contains "filter_poodll_" or similar. I.e. if it's a "Page", and the plugin is about to render it as a modal, do a final check on the content for some text that will appear only in Poodll pages. If it's there, abort. Would that work? It may enable people to use pages that did not contain Poodll for now until a proper fix.

    Longer term, subject to level of effort, I'd like to fix it if possible. I have not looked at Poodll much yet, though from what I have seen it looks great. If there's a setup guide somewhere dealing with this type of activity, which could enable me to replicate the problem quickly in test, it'd probably be worth me doing that eventually.

  2. Justin Hunt reporter

    I do not think its urgent enough to do anything adhoc. Probably simpler than Poodll is Generico which works the same way. Any of the templates which has Javascript in it will have the same results. I tested with the "Toggle" and "Abacus" templates.

    I checked and the AMD module is init'ed when the Page is not shown in a modal, but it is not init'ed when it is shown in a modal. I guess the format_text will prepare the javascript to be sent out to the page footer when renderer->footer() is called. But if it is not called, or if the output from renderer->footer() does not make it to the page then that would cause this. Thats just an off the top of my head analysis, not based on looking at the code.

    I think just keep any eye out for it, but its not urgent. If you need any help reproducing the problem with Generico, then let me know.

    Justin

  3. Valentin Krendl

    Hi David,

    Our Teachers really like the tiles format and would like to use generico-elements in the tiles-modals too.

    Is there an update on this subject or do you know of a workaround?

    Thanks

    Valentin

  4. Log in to comment