Created
February 9, 2012 20:23
-
-
Save FlaviuSim/1782822 to your computer and use it in GitHub Desktop.
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
jQuery('a.add-question').live('click', function(e) { | |
e.stopPropagation() | |
e.preventDefault() | |
var form_el = jQuery(this).parents('form') | |
var num_questions = form_el.find('.question').length | |
var new_question_el = form_el.find('.question:last').clone() | |
new_question_el.appendTo('.questions',form_el).hide().slideDown("fast") | |
new_question_el.find('label,select,input,textarea').each(function(e) { | |
var el = jQuery(this) | |
_.each([ 'class', 'id', 'for','name' ], function(attr_name) { | |
var attr_val = el.attr(attr_name) | |
if(attr_val) { | |
attr_val = attr_val.replace( /_\d+_/, "_"+total_qus+"_" ) | |
attr_val = attr_val.replace( /\[\d+\]/, "["+total_qus+"]" ) | |
el.attr( attr_name, attr_val ) | |
} | |
}) | |
}) |
iamdustan
commented
Feb 9, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment