Reputation: 47310
I have a spring form, with backing object that includes a LazyList - works hunky dory.
The form initally shows:
<tr><td>
<form:textarea path="myList[0]" cssClass="myClass" rows="2" cols="35"/>
</td><tr>
<tr><td>
<form:textarea path="myList[1]" cssClass="myClass" rows="2" cols="35"/>
</td><tr>
When a user focusses on the final textarea I want another one to be appended. The html and javascript I have OK, its the binding to the spring backing object that is a problem, my javascript so far:
var myStr = '<tr><td>'+
'<form:textarea path="myList[2]" cssClass="myClass" rows="2" cols="35"/>'+
'</td><tr>'
function myAppend(){
jq('#myTable tr:last').find("textarea").unbind('focus');
jq('#myTable tr:last').after(myStr);
jq('#instructionTable tr:last').find("textarea").bind('focus', function() {
myAppend();
});
}
However the rendering is screwed up ... any tips ?
I've found this, which performs and ajax call for each new line. Is their any other option ?
Upvotes: 0
Views: 1340
Reputation: 845
The spring <form:textarea ... />
tag is evaluated on server side.
It renders the according HTML Element based on the given tag parameters.
So a:
<form:textarea path="name"/>
is rendered to
<textarea id="name" name="name"></textarea>
So you have to append a <textarea />
Element with your javascript.
The reason for using the tag is to bind the submited value to the 'commandBean' provided by your spring controller.
Upvotes: 1