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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

How to change View with JavaScript?

TomasCharvat
14-Alexandrite

How to change View with JavaScript?

Hello,

 

I know that I can navigate to other view with button event.

But I need to create a function which change view only if something happen.

 

So how can I change view with a JavaScript?

 

Thanks for every answer.

 

Tomas

1 ACCEPTED SOLUTION

Accepted Solutions

make a new view 'prova'

and make a script :

 

$scope.go=function() {

twx.app.fn.navigate("prova");
};

 

assign go to click event 

 

 

Giuseppe

 

View solution in original post

7 REPLIES 7

$scope.app.fn.navigate('Enter View Name Here');                                 //navigate to other View

make a new view 'prova'

and make a script :

 

$scope.go=function() {

twx.app.fn.navigate("prova");
};

 

assign go to click event 

 

 

Giuseppe

 

Hi,

 

I am having issues trying to replicate this behavior and was wondering if you can see what I'm doing wrong? I am working on Hololens but I don't believe this should affect anything.

 

I have 2 'views', the first is 'Home' (The name, Studio ID and friendly name are all the same) and the second 'H&S' (again the name, Studio ID and friendly name are all the same)

 

In the Home.js I have:

$scope.go=function() {
twx.app.fn.navigate("H&S");
};

On the swipe right application event (I have tried on a click event as well) I call the function:

go();

But the scene does not change in the preview. 

 

Any advice would be great. 

Thanks

for the Hololens modify the script in :

 

 

$scope.app.go=function() {
twx.app.fn.navigate("H&S");
};

 

and the call 

 

app.go();

 

I hope to help you

 

Giuseppe

Hi,

 

Thanks for the quick reply but unfortunately that hasn't resolved the issue. 

 

I did try making a new experience to see if it was something else in the script causing the fault but that made no difference...

 

Any other ideas?

 

I tried the same and it worked, changed the view ...... on double tap event.

 

 

 

I had a project where I had some difficulties to call it. In this case I managed to get it working using some delay with asynchronous function call. So I used some code like this:

 

////////////////////////////////////////
$scope.app.doorInstructions = function(){
  console.warn("called door Instruction");
  $timeout( function() {
    //start timeout
    $scope.$applyAsync( // start applyAsync
      function() {
        //start the intented steps 
//-toggel the button back and go to view $scope.view.wdg['toggleButton-2']['pressed']=false; $scope.app.fn.navigate('Instructions'); } //finish def ); //finish applayAsync } , 1000); //finish timeout function // };
/////////////////////////////////////////

May be , this could be helpful also in your case. 

An  other point is the name ... should it contain &... no idea if this also contribute to the issue...

 

Top Tags