Created
July 16, 2012 10:42
-
-
Save ikwattro/3122080 to your computer and use it in GitHub Desktop.
protoype field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addFieldForm(collectionHolder, $newLinkLi) | |
{ | |
var prototype = collectionHolder.attr('data-prototype'); | |
var newForm = prototype.replace(/__name__/g, collectionHolder.children().length); | |
var $newFormLi = jQuery('<li></li>').append(newForm); | |
$newLinkLi.before($newFormLi); | |
} | |
var collectionHolder = jQuery('#unimog_contenttype_fieldbundle_contenttypetype_fields'); | |
var $addFieldLink = jQuery('<a href="#" class="add_field_link">Add a field</a>'); | |
var $newLinkLi = jQuery('<li></li>').append($addFieldLink); | |
jQuery(document).ready(function() | |
{ | |
collectionHolder.append($newLinkLi); | |
$addFieldLink.on('click', function(e){ | |
e.preventDefault(); | |
addFieldForm(collectionHolder, $newLinkLi) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment