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