Forums / Templates, Stylesheets, Page Layout / Checkout_payement : $('.paymentSubmit').attr('disabled', true) - shouldn' be the ID ?

Checkout_payement : $('.paymentSubmit').attr('disabled', true) - shouldn' be the ID ?

Views: 545

Results 1 to 2 of 2
6 Oct 2016, 10:04 AM
#1
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Checkout_payement : $('.paymentSubmit').attr('disabled', true) - shouldn' be the ID ?

Hi
I had to change the relate main_jscript chechout_payment page, to load on the footer, since I have jquery at the footer.

So I was using inside the $(document).ready, the <?php if ($current_page == 'checkout_payment') { ?>
and all the code that uses jquery from chechout_payment (modules/page) was in there.

But Looking at page speed in google, and all that webmaster slavery, I see now that I have to use some "defer" to load the page content faster.

Anyway, as I was looking at the code again, I think I've spoted something ( or not ) :

$('.paymentSubmit').attr('disabled', true);

I don't see any class in tpl_checkout_payment_default.php ( the default file ) .

Shouldn't this be targeting the ID instead of the class ?

Another question, that maybe you can help me:

I'm using a gulp file that compacts all the jquery to one file. So the $(document).ready is the last file to include.
But at this piece on code ( the above one ) , there's a
<?php if ($flagOnSubmit) { ?>

$(document).ready(function(){
      $('form[name="checkout_payment"]').submit(function() {
          $('.paymentSubmit').attr('disabled', true);
        <?php if ($flagOnSubmit) { ?>
          formPassed = check_form();
          if (formPassed == false) {
              $('.paymentSubmit').attr('disabled', false);
          }
          return formPassed;
        <?php } ?>
      });
    });

How can I detect the $flagOnSubmit in a "javascript way" , so I dont' need the php tag, and I can include all this stuff safely at the end of the y last include js file ?

ok
Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

6 Oct 2016, 11:13 AM
#2
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Checkout_payement : $('.paymentSubmit').attr('disabled', true) - shouldn' be the ID ?

moving a step futher ( I think )

At the includes\modules\pages\checkout_payment\jscript_main.php
I've added this :

<?php if ($flagOnSubmit) { ?>
    var flagOnSubmit = 1;        
<?php } ?>

So I can remove that bit of code with jquery that I mentioned to my last .js file to compacted since I have a **var flagOnSubmit **

if ( document.body.id == 'checkoutpaymentBody' ) {
     $('form[name="checkout_payment"]').submit(function() {
         $('.paymentSubmit').attr('disabled', true);
        if ( flagOnSubmit == 1 )
          formPassed = check_form();
          if (formPassed == false) {
              //document.getElementsByClassName ('payment')
              $('.paymentSubmit').attr('disabled', false);
          }
          return formPassed;
       
      });
  }

But, I' not sure if it's working as expect :

On checkout_payment page , ie: with 2 payment methods , if I select none , one pop up comes up , but then the page is reloaded , not sure if this is ok ... actually this site only has 1 payment method.

In terms on attr disable, etc... I see no changes....

Well, it's working, but I'm not sure if this is ok.

Tahnks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison