0 Replies Latest reply on Nov 25, 2013 6:57 AM by Enrico Morelli

    jQuery to rich:jQuery

    Enrico Morelli Newbie

      Dear,

       

      I've the following snippet of code that works fine. How can I translate to use with rich:jQuery?

       

      $(function() {
      $('#acchide').hide();
        $('#haveacc1').click(function() {
          $('#acchide').show();
        });
        $('#haveacc2').click(function() {
            var list = $('input').filter('[name^=accpers]');
          for (i=0; i<list.length; i+=1) {
              if ($(list[i]).val()) {
                  $(list[i]).attr("value","");
              }
          }
          
          $('#acchide').hide();
        });
      });
        
      
      function add(id) {
      t = id.split('_')[1];
      newid = parseInt(t)+1;
      $('<span id="accinput_'+newid+'"><br />Name and surname <input type="text" name="accpers" id="accpers_'+newid+'"><img src="/emboworkshop/images/plus.gif" id="plus_'+newid+'" onClick="add(this.id)"><img src="/emboworkshop/images/minus.gif" id="minus_'+newid+'" onClick="remove(this.id)"></span>').insertAfter($('#accinput_'+t));
      }
      
      function remove(id) {
      t = id.split('_')[1];
      id = 'accinput_'+t;
      if ( t > 1 ) {
          $('span').filter('[id='+id+']').remove();
      }
      }
      
      ....
      ....
      <div class="form-item">
                  <label for="AccPers">Do you have accompanying persons</label>
                  <input type="radio" id="haveacc1" name="haveacc" value="1" class="form-radio" />Yes
                  <input type="radio" id="haveacc2" name="haveacc" value="0" class="form-radio" checked />No
                  <div id="acchide">
                      <span id="accinput_1"><br />Name and surname <input type="text" name="accpers" id="accpers_1" />
                      <img src="/chianti12/images/plus.gif" id="plus_1" onClick="add(this.id)">     
                      </span>        
                  </div>
              </div>