Translate Prototype code into Jquery version

Posted by user1055495 on Stack Overflow See other posts from Stack Overflow or by user1055495
Published on 2011-11-19T16:45:17Z Indexed on 2011/11/19 17:51 UTC
Read the original article Hit count: 203

I everybody, I'm working on a SaaS application and I need to use Jquery instead of Prototype due to some extra plugins integration. My code that was wotking a charm with Prototype is not running anymore with Jquery and I'm not used to write in this framework... Is there someone to help me in "translating" this one: Thanks a lot for your help.

var rates = new Array();

<% for tva_rate in @tva_rates -%>

  rates.push(new Array(<%= tva_rate.id %>, '<%=h tva_rate.taux %>', '<%=h tva_rate.compte_id %>' ));

<% end -%>

function tvaSelected() {


  tva_id = $('journal_tva_id').getValue();

  show = 1;
  if (tva_id > 0){
    rates.each(function(rate) {
        if (rate[0] == tva_id) {
            $('journal_taux').setValue(rate[1]);
            $('journal_compte_tva').setValue(rate[2]);
            show = 2;
        }
    });
}

  if (show == 1) {
    $('tva_taux_field').hide();
  } else {
    $('tva_taux_field').show();
  }
}
document.observe('dom:loaded', function() {
  tvaSelected();
  $('journal_tva_id').observe('change', tvaSelected);
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery