Commit | Line | Data |
---|---|---|
2bf0718d J |
1 | // Updated to wait until the document is loaded. addmore_link |
2 | ||
2bf0718d J |
3 | cj(function ( $ ) { |
4 | ||
b18480e2 J |
5 | $('#addmore_link').on('click', function( e ) { |
6 | e.preventDefault(); | |
7 | var count = parseInt($('input[name=contrib_count]').val()); | |
8 | count++; | |
9 | ||
10 | var c_page_sel = $('select[name=contribution_page_1]').clone().attr('id', 'choices_' + $(this).index()); | |
11 | c_page_sel.attr("id", "contribution_page_" + count); | |
12 | c_page_sel.attr("name", "contribution_page_" + count); | |
13 | ||
14 | var id_section = "crm-section-con-" + count; | |
15 | var sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <div class=\"label\"><label>Contribution Page</label>"; | |
16 | $('#addmore_link').parent().parent().before(sect_tag); | |
17 | ||
18 | var id_content = "content_con-" + count; | |
19 | $('#' + id_section).append("<div class=\"content\" id="+ id_content + ">"); | |
20 | $('#' + id_content).append(c_page_sel); | |
21 | $('#' + id_content).append('<a id=\"remove_link\" class=\"form-link\" href=\"remove\" name=\"remove_link-' + count + '\"> Remove</a>'); | |
22 | $('#' + id_section).append("</div"); | |
23 | ||
24 | id_section = "crm-section-per-" + count; | |
25 | sect_tag = "<div class=\"crm-section\" id=" + id_section + "> <div class=\"label\"><label>Percentage</label>"; | |
26 | $('#addmore_link').parent().parent().before(sect_tag); | |
27 | ||
28 | id_content = "content_per-" + count; | |
29 | $('#' + id_section).append("<div class=\"content\" id="+ id_content + ">"); | |
30 | $('#' + id_content).append('<input type="text" size="20" name="percentage_' + count +'" value="" />'); | |
31 | $('#' + id_section).append("</div"); | |
32 | ||
33 | $('input[name=contrib_count]').val(count); | |
34 | }); | |
2bf0718d | 35 | |
b18480e2 J |
36 | $('#remove_link').live('click', function( e ) { |
37 | e.preventDefault(); | |
38 | ||
39 | var rem_name = e.target.name; | |
40 | //assuming that - is the delimiter. second string will be the count | |
41 | var rem_name_ar = rem_name.split('-'); | |
42 | var contri_page = "\"#percentage_" + rem_name_ar[1] + "\""; | |
2bf0718d | 43 | |
b18480e2 J |
44 | $('#crm-section-con-'+ rem_name_ar[1] +'').remove(); |
45 | $('#crm-section-per-'+ rem_name_ar[1] +'').remove(); | |
2bf0718d | 46 | |
2bf0718d | 47 | }); |
b18480e2 | 48 | |
2bf0718d | 49 | }); |