// Updated to wait until the document is loaded. addmore_link
cj(function ( $ ) {
-
+ $(document).ready(function(){
+ var count = parseInt($('input[name=contrib_count]').val());
+ for ( var i = 2; i <= count; i++ ) {
+ $('#' + "contribution_page_" + i).after(
+ '<a id=\"remove_link\" class=\"form-link\" href=\"remove\" name=\"remove_link-' + i + '\"> Remove</a>');
+ $('#' + "contribution_page_" + i).parent().parent().attr("id", "crm-section-con-" + i);
+ $('#' + "percentage_" + i).parent().parent().attr("id", 'crm-section-per-' + i);
+ }
+ $('#percentage_1').after('<label><br><SMALL>Progressbar shows the sum of each percentage of contributions done on each selected contribution page</SMALL></label>');
+ });
$("#ProgressBar").validate({
rules: {
starting_amount: {
c_page_sel.attr("name", "contribution_page_" + count);
var id_section = "crm-section-con-" + count;
- var sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <div class=\"label\"><label>Contribution Page</label>";
+ var sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <hr width='50%' size='1'> <div class=\"label\"><label>Contribution Page</label>";
$('#addmore_link').parent().parent().before(sect_tag);
var id_content = "content_con-" + count;
$('#' + id_section).append("<div class=\"content\" id="+ id_content + ">");
$('#' + id_content).append(c_page_sel);
$('#' + id_content).append('<a id=\"remove_link\" class=\"form-link\" href=\"remove\" name=\"remove_link-' + count + '\"> Remove</a>');
- $('#' + id_section).append("</div");
+ $('#' + id_section).append("</div>");
id_section = "crm-section-per-" + count;
sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <div class=\"label\"><label>Percentage</label>";
});
- $('#remove_link').live('click', function( e ) {
+ $(document).on('click', '#remove_link', function( e ) {
e.preventDefault();
var rem_name = e.target.name;
//assuming that - is the delimiter. second string will be the count
var rem_name_ar = rem_name.split('-');
var contri_page = "\"#percentage_" + rem_name_ar[1] + "\"";
-
$('#crm-section-con-'+ rem_name_ar[1] +'').remove();
$('#crm-section-per-'+ rem_name_ar[1] +'').remove();
-
+ var count = parseInt($('input[name=contrib_count]').val());
+ count--;
+ $('input[name=contrib_count]').val(count);
});
-
});