Question

I am using Marionette and jQuery Mobile to build a single page app. The various parts of the page are made from templates filled with data from Web SQL.

I read in JQM's documentation that to force JQM to enhance dynamically created pages trigger('create') should be used. The examples show that trigger should be called immediately upon injecting the new markup like so:

$( ...new markup that contains widgets... ).appendTo( ".ui-page" ).trigger( "create" );

In my case the markup is injected by Marionette (i.e. a Collection View loops through its associated models, applying the appropriate template each time. So -- and here is the problem -- on which event should I bind trigger('create') to make the dynamic markup appear enhanced?

Was it helpful?

Solution

FYI, it turns out that the current version of Marionette (v1.0.0-beta5) doesn't seem to fire an event after a view's contents have been added to the DOM (see here). A workaround is for the code that uses the view -- and knows that it has just added the view's contents to the DOM -- to do the work itself. This may not be very nice (e.g. a view cannot take care of its own affairs) but it works. More information on this may be found here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top