1

I have the following in my viewmodel:

 dialog.getContext().reposition(vm);

But it's not working, because I'm supposed to be passing the view, not the viewmodel. How can I - from within a viewmodel - get access to its corresponding view?

SB2055
  • 12,272
  • 32
  • 97
  • 202

1 Answers1

2

To Access the view from your viewModel You have detached,compositionComplete, attached, and compositionComplete handlers to choose from.

For example from attached:

function attached(view, parent) {
   console.log("This is the current view",view);//this will log the view HTML
  $(view).find(".smallLoader").fadeOut();// Now fadeOut .smallLoader from this view
}

var viewModel = {
    activate: activate,
    title: 'Home',
    attached: attached
};

return viewModel;
Gildas.Tambo
  • 22,173
  • 7
  • 50
  • 78
  • You have access to the view from binding, bindingComplete, attached, compositionComplete and detached. Not activate – CarlesD Nov 19 '14 at 16:43