Sha256: 5425cf79264b9d57f50adca60b8b2954274d4fad173da090207d5b3a8e0d4737

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

function setUpDocument($jq) {

  $jq.find("input[type|=text][data-auto-complete|=true]").each( function(idx, el){
    $(el).autocomplete({
      source: $(el).attr('data-auto-complete-url'),
      minLength: 2
    });   
  });

  $jq.find("a.add-child-link").click( function() {
    klass = $(this).attr('data-class-name');
    $el = $(this).prev().children().first().clone();
    new_id=new Date().getTime()
    $el.html($el.html().replace(new RegExp('__'+klass+'_id__', 'g'), new_id));
    $el.find('input[data-remove|='+klass+']').attr('value', 'false');
    $(this).closest('.child').find('.'+klass+'_children').first()
        .append($el).show();
    setUpDocument($el);
    return false;
  });
  
  $jq.find('a.remove-child-link').click( function() {
    $(this).prev('input[type|=hidden]').val('1');
    $(this).closest('.child').hide();
    return false;    
  });
}

$(function () {  
  setUpDocument($("body"));
  
});  


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anaf_habtm-0.0.85 lib/generators/anaf_habtm/assets/nested_attributes.js
anaf_habtm-0.0.84 lib/generators/anaf_habtm/assets/nested_attributes.js