Search code examples
javascriptmodel-view-controllerbackbone.jsmarionettebackbone-views

Manipulate Marionette ItemView using its cid


// Global scope
A1= Marionette.ItemView.extend({ ... });

// Inside a function, local scope
var a1= new A1;

When I console.log(a1), where a1 is defined as shown above. I see that a1 has a unique
cid: "view32"

My question is how can I get hold of View a1 (where a1 is a local variable inside a function) using its cid. Does Marionette have a global object (there must be one - imo) containing the list pair of (reference to) Views currently rendered in the DOM and their respective cid's?

(P.S. I am not talking about a user created global Marionette.Application() object but an object which Marionette uses internally to keep track of currently rendered Views in DOM)


Solution

  • You can't. Marionette's view cids are in fact Backbone's view cids which are being generated upon object creation using underscore.js' uniqueId method. View instances are not being held in global context.