0

In file html i write

 <div data-bind=" $parent.checkPaymentPage() ">...</div> 

In file js i have

checkPaymentPage: function(){
    console.log(1);
}

But when i call and reload it not console.log(1). How can i call it? Please help me!

  • Any console error ? – Pawan Jul 27 '20 at 5:07
  • Did you run the static content command after adding/updating the JS/HTML code? Also please clear your browser cache to review the changes. – Nits Jul 27 '20 at 6:12
  • yes any console.as long as I call the checkPaymentPage function – Boll Jul 27 '20 at 6:26
1

in the knockout HTML you can use the data-bind with the various binding map

in order to just call the component file function, you can use data-bind with afterRender so whenever you div was loaded this function call.

<div data-bind="afterRender: checkPaymentPage">...</div> 

in the js file you can write the function.

checkPaymentPage: function(){ console.log(1); },

Ex. if you are using an observable variable

isVisible: ko.observable(false),
isLoading: ko.observable(false),

You can use the below code

<div data-bind="fadeVisible: isVisible() , blockLoader: isLoading()" id="component-container">.....</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.