Created
April 24, 2010 15:10
-
-
Save zenom/377701 to your computer and use it in GitHub Desktop.
This file contains 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
$(document).ready(function() { | |
$("div.fade").fadeTo(10000, 1).fadeOut("slow"); | |
/* Copy a row, change the input field names and append to table */ | |
$("a.add-row").click(function(e) { | |
e.preventDefault(); | |
var copy_row = $("table").find("tbody tr").first().clone() | |
var existing_rows = parseInt($("table").find("tbody tr").length) | |
/* alternating row colors */ | |
if(existing_rows % 2) { | |
$(copy_row).removeClass("odd"); | |
$(copy_row).addClass("even"); | |
} | |
$(copy_row).find("input,select").each(function() { | |
var name = $(this).attr("name").split("-"); | |
var new_name = name[0]+ "-" + existing_rows + "-" + name[2]; | |
//alert(new_name); | |
$(this).attr("name", new_name); | |
$(this).attr("id", new_name); | |
//$(this).val(""); | |
console.log($(this).attr("name")); | |
console.log($(this)); | |
}); | |
$(copy_row).find("td a").each(function() { | |
$(this).attr("href", ""); | |
}) | |
$("table tr:last").after(copy_row); | |
}); | |
}); |
This file contains 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
<tbody><tr class="odd"><td> | |
<input class="mini text" id="urls-0-subdomain" name="urls-0-subdomain" type="text" value="" /></td><td> | |
<input class="short text" id="urls-0-domain" name="urls-0-domain" type="text" value="" /></td><td> | |
<input checked="checked" class="short text" id="urls-0-blogroll" name="urls-0-blogroll" type="checkbox" value="y" /></td><td> | |
<select class="short text" id="urls-0-post_filter" name="urls-0-post_filter"><option selected="selected" value="none">No-Filter</option><option value="nolinks">No-Links</option></select></td></tr></tbody> |
This file contains 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
UnicodeMultiDict([('name', u'Test Blog'), ('urls-0-subdomain', u''), ('urls-0-domain', u''), ('urls-0-blogroll', u'y'), ('urls-0-post_filter', u'none'), ('some_name', u'Create Blog')]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment