cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

when using a model selection list, how to have one loaded by default ?

SoretteMichel
12-Amethyst

when using a model selection list, how to have one loaded by default ?

Hello everyone,

I'm working on an experience for which i will use a list to switch between models as described in the help topic here : PTC

It's working very well, the only issue i have is that i would like to have one of the models to be loaded and displayed by default.

Anyone knows how to achieve that ? I guess it's in the home.js code but i can't find out how to do it myself.

Any help will be appreciated.

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
mwassmann
5-Regular Member
(To:SoretteMichel)

yeah, i thought so ... 🙂

I just tried some code and what you can do is to add some js to override the behavior - e.g.

$scope.populateModelList = function() {



  $scope.app.params.modelselect = [

  {

    display: "Chessboard",

    value: "app/resources/Uploaded/pik.pvz"

  },

  {

    display: "Blue Pump",

    value: "app/resources/Uploaded/sigmatile_anim.pvz"

  }

  ];

 

}

$scope.populateModelList();


// above is the old code for the select widget



$timeout(function() {


$scope.setmodel = function() {

 

$scope.view.wdg['model-1']['src']= "app/resources/Uploaded/pik.pvz";

 

}


$scope.setmodel();


},100);


View solution in original post

4 REPLIES 4
mwassmann
5-Regular Member
(To:SoretteMichel)

Hej Michel,

I havent yet seen the example - but i suppose you havent set any resource for model-1 (due to doing it dyanmically through a list).

So I would try to set a model resource fixed under model-1 for your "default" model.

If that doesn't work (or makes the list selection not working) I will tell you a way via javascript.

Martin

Hey Martin,

Thanks for your quick answer. That's what i've tried first but it looks like the list overule the model ressource set manually. Whatever i set there, nothing is loaded by default (but still the list works well).

Thanks,

mwassmann
5-Regular Member
(To:SoretteMichel)

yeah, i thought so ... 🙂

I just tried some code and what you can do is to add some js to override the behavior - e.g.

$scope.populateModelList = function() {



  $scope.app.params.modelselect = [

  {

    display: "Chessboard",

    value: "app/resources/Uploaded/pik.pvz"

  },

  {

    display: "Blue Pump",

    value: "app/resources/Uploaded/sigmatile_anim.pvz"

  }

  ];

 

}

$scope.populateModelList();


// above is the old code for the select widget



$timeout(function() {


$scope.setmodel = function() {

 

$scope.view.wdg['model-1']['src']= "app/resources/Uploaded/pik.pvz";

 

}


$scope.setmodel();


},100);


Works like a charm !

You're the man

Top Tags