[jQuery] Unable to get the latest text/value inside a textarea

[jQuery] Unable to get the latest text/value inside a textarea


Now, I was not expecting this. You can get the text inside the
textarea using something like:
alert($('#id_of_textarea').text());
That works, but if you bind it with an event, let’s say onkeyup — you
will never get the “latest” text inside the textarea. This was a
complete surprise to me. The best way to do it would be to use the attr
(’value’)
In the example below CustomerNotes is a textarea and it doesn't matter
how I try to get the current value I end up getting the old value. I
have tried using $(#..).val() and $(#..).text.
Any suggestions or advice would be greatly appreciated
Thanks,
Joel
<code>
$("#save_forecast").die("click");
$("#save_forecast").live("click", function() {
$.ajax({
type: 'POST',
url: '/core/forecasts/SaveComputeForecast',
data: { "request.Id": "<%=Model.Id %>",
"request.StartDate": $("#StartDate").val(),
"request.EndDate": $("#EndDate").val(),
"request.ResourceAmountRequested": $
("#ResourceAmountRequested").val(),
"request.OS": $("#OS").val(),
"request.MemorySizeInGb": $("#MemorySizeInGb").val
(),
"request.CustomerNotes": $("#CustomerNotes").text
()
},
beforeSend: function() {
},
success: function(data, textStatus) {
$("#forcast_content").fadeOut('slow', function() {
$("#forcast_content").html("<center>Forecast
saved</center>");
$("#forcast_content").fadeIn('slow');
$.PopulateCurrentComputeForecastTable();
});
},
complete: function() {
}
});
</code>