Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to navigate to a view with oj-button

User_INPR6May 12 2021

I’m trying to create a button that jumps to another view when clicked. I created the Button like this:

 <button class="oj-button-primary"
        data-bind="click: test,
                   ojComponent: {
                       component: 'ojButton',
                       label: 'test'
                   }">              
</button>

My ViewModel looks like this:

define(['jquery','appController', 'accUtils', 'ojs/ojbutton' ],
 function() {
    function AboutViewModel() {
      
        var self = this;
        self.test = function() {
        router.rootInstance.go('start');
        };
    }
    return AboutViewModel;
  }
);

When i press the button i get following error:

Uncaught ReferenceError: router is not defined
    at AboutViewModel.self.test (about.js:17)
    at HTMLButtonElement.<anonymous> (knockout-3.5.1.debug.js:4669)
    at HTMLButtonElement.dispatch (jquery-3.5.1.js:5429)
    at HTMLButtonElement.elemData.handle (jquery-3.5.1.js:5233)
	AboutViewModel.self.test	@	about.js:17
	(anonymous)	@	knockout-3.5.1.debug.js:4669
	dispatch	@	jquery-3.5.1.js:5429
	elemData.handle	@	jquery-3.5.1.js:5233

I also tried to work it out with JQuery. I think I must have made a pretty obvious mistake somewhere, but i cant figured out where.
Thank you

This post has been answered by Philip Sommer on May 14 2021
Jump to Answer
Comments
Post Details
Added on May 12 2021
3 comments
507 views