0

i have a custom form.html that displays at checkout. i want to have a javascript tag - when the form load just show an alert testing purposes.

code i used below,

"<script type="text/javascript">
require(['jquery', 'jquery/ui'], function($){ 
    $('document').ready(function(){
        console.log("this")
        alert('Load');
        document.getElementById('pinverify').style.display = "none";
        document.getElementById('labelBalance').style.display = "none";

        document.getElementById('payment[custom_field_one]').value =""; 
        document.getElementById('OTP').value= "";
        document.getElementById('payment[custom_field_three]').value = "";

   $('#verify').click(function(){

       checkOTPField();

    });
"

but this alias does not work, is there a different alias used in magento 2?

Thank you

5
  • Can you give the path to this .html file. Sep 26, 2018 at 13:51
  • [namespace]/[ModuleName]/view/frontend/web/template/payment/form.html Sep 26, 2018 at 13:54
  • Can you describe your purpose? Sep 26, 2018 at 14:15
  • i have created a custom form i have a textbox on the form aswell as a button i would like to run the javscript for that button within the html form $(button).click function - but its not allowing me to do that Sep 26, 2018 at 14:47
  • Hey have you override this from (web/template/payment/form.html) from any core module? @RadhiyahWilliams Sep 27, 2018 at 6:54

1 Answer 1

0

Assuming that you checked and do not have any error in your js code. Possible reason for the changes to not reflect is that you did not run the content:deploy command after making the changes:

Please run the below commands:

bin/magento cache:clean
bin/magento setup:static-content:deploy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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