Skip to content

Commit

Permalink
Fixed bug in - Complex dynamic rows
Browse files Browse the repository at this point in the history
  • Loading branch information
erikuus committed Oct 4, 2011
1 parent c2cafc3 commit 343778d
Show file tree
Hide file tree
Showing 6 changed files with 302 additions and 281 deletions.
30 changes: 15 additions & 15 deletions css/form.css
Expand Up @@ -161,7 +161,7 @@ select

input.autocomplete
{
background: #FFFFE0;
background: #FFFFE0;
}

input.readonly
Expand Down Expand Up @@ -222,29 +222,29 @@ div.errorMessage
color: #C00;
}

label.error
label.error
{
display: block;
display: block;
}

div.add
{
cursor: pointer;
width: 60px;
padding: 2px;
border: 1px solid #a6c9e2;
color: #0066a7;
text-align: center;
cursor: pointer;
width: 60px;
padding: 2px;
border: 1px solid #a6c9e2;
color: #0066a7;
text-align: center;
}

div.remove
{
cursor: pointer;
width: 60px;
padding: 2px;
border: 1px solid #a6c9e2;
color: #0066a7;
text-align: center;
cursor: pointer;
width: 60px;
padding: 2px;
border: 1px solid #a6c9e2;
color: #0066a7;
text-align: center;
}

textarea.template
Expand Down
14 changes: 14 additions & 0 deletions js/jquery.calculation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions js/template.js
@@ -1,31 +1,31 @@
/**
* jQuery script for adding new content from template field
*
*
* NOTE!
* This script depends on jquery.format.js
*
* IMPORTANT!
*
* IMPORTANT!
* Do not change anything except specific commands!
*/
jQuery(document).ready(function(){
removeEmptyHeads();
jQuery(document).ready(function(){
hideEmptyHeaders();
$(".add").click(function(){
var template = jQuery.format(jQuery.trim($(this).siblings(".template").val()));
var place = $(this).parents(".templateFrame:first").children(".templateTarget");
var i = place.children(".templateContent").size();
var i = place.find(".rowIndex").length>0 ? place.find(".rowIndex").max()+1 : 0;
$(template(i)).appendTo(place);
place.siblings('.templateHead').show()
// start specific commands

// end specific commands
});
$(".remove").live("click", function() {
});

$(".remove").live("click", function() {
$(this).parents(".templateContent:first").remove();
removeEmptyHeads();
hideEmptyHeaders();
});
});

function removeEmptyHeads(){
function hideEmptyHeaders(){
$('.templateTarget').filter(function(){return $.trim($(this).text())===''}).siblings('.templateHead').hide();
}

0 comments on commit 343778d

Please sign in to comment.