+ Start a Discussion

How to add multiple input fields of child record in parent record page in visualforce?

I am trying to accomplish something like this jsfiddle in my parent object VF page (input fields are from child object of this parent):  http://jsfiddle.net/yahavbr/eW6j4/

Here is the js code I have written for my VF page (this VF has custom controller & extension)
    var maxField = 10; //Input fields increment limitation
    var addButton = $('.add_button'); //Add button selector
    var wrapper = $('.field_wrapper'); //Input field wrapper
    var fieldHTML = '<div><apex:inputField value="{!objectLineItem.Line_Type__c}" style="width:3rem; float:left;"/><apex:inputField value="{!objectLineItem.Line_Description__c}" style="width:5rem; float:left;"/><apex:inputField value="{!objectLineItem.Journal__c}" style="width:3rem; float:left;"/><apex:inputField value="{!objectLineItem.General_Ledge_Account__c}" style="width:4rem; float:left;"/><apex:inputField value="{!objectLineItem.Amount__c}" style="width:5rem;  float:left;"/><apex:inputField value="{!objectLineItem.Tax_Code__c}" style="width:5rem; float:left;"/><apex:outputText value="{!objectLineItem.Tax_Amount__c}" style="width:3rem; float:left;"/><apex:outputText value="{!objectLineItem.Total_Amount__c}" style="width:3rem; float:left;"/><apex:inputField value="{!objectLineItem.Dimension_1__c}" style="width:6rem; float:left;"/><a href="javascript:void(0);" class="remove_button" title="Remove field">Remove</a></div>';
    var x = 1; //Initial field counter is 1
    $(addButton).click(function(){ //Once add button is clicked
        if(x < maxField){ //Check maximum number of input fields
            x++; //Increment field counter
            $(wrapper).append(fieldHTML); // Add field html
    $(wrapper).on('click', '.remove_button', function(e){ //Once remove button is clicked
        $(this).parent('div').remove(); //Remove field html
        x--; //Decrement field counter

The same script was working fine in the browser for html (input field), but when I am trying it in Salesforce, it;s not working. 
Add multiple input fields of child object in the parent's VF page
Not sure, why it's not working, I think, JS file is ok, problem with either Custom controller, or something else. Any suggestion?