Search code examples
magentotranslate

Jquery -> prototype translate


Can anyone help me translate this to prototype

var btn = $('#onestepcheckout-button-place-order');
var btnTxt = $('#onestepcheckout-button-place-order span span span');

var fewSeconds = 10;

btn.click(function(){

    btn.prop('disabled', true);
    btnTxt.text('Even geduld A.U.B.');
    btn.addClass('disabled');

    setTimeout(function(){
        btn.prop('disabled', false);
        btnTxt.text('Bestelling plaatsen');
        btn.removeClass('disabled');


    }, fewSeconds*1000);

});

Prototype is confusing the sh*t out of me


Solution

  • Try this:

    var btn = $('onestepcheckout-button-place-order');
    var btnTxt = $$('onestepcheckout-button-place-order span span span')[0];
    
    var fewSeconds = 10;
    
    Event.observe(btn, 'click', function(){
    
        btn.setAttribute('disabled', 'disabled');
        btnTxt.innerHTML = 'Even geduld A.U.B.';
        btn.addClassName('disabled');
    
        setTimeout(function(){
            btn.removeAttribute('disabled');
            btnTxt.innerHTML = 'Bestelling plaatsen';
            btn.removeClassName('disabled');
        }, fewSeconds*1000);
    
    });
    

    I haven't tested it though.