Closed Crisfole closed 11 years ago
Cool, looks like a nice solution to this problem. I wonder if adding a change handler would get the same effect. So instead of:
textarea.bind("input.expanding propertychange.expanding keyup.expanding", resize);
if we did:
textarea.bind("input.expanding propertychange.expanding keyup.expanding change.expanding", resize);
Would that solve the problem without needing the extra call?
Totally possible. I assume change.expanding
is an event triggered manually in expandingTextarea
? textarea
and input
don't fire change events when setting by val
Oh, I was assuming that it would automatically fire. I see now that it doesn't fire when set with val()
. I think your solution is probably better. I guess you could manually run:
$(this).val("something").trigger("input.expanding")
But I'm fine with adding this to the API to make it easier to remember.
I used to run it that way, but got sick of repeating myself.
Closing this due to the updates in https://github.com/bgrins/ExpandingTextareas/pull/31. Not perfect, but you can now call:
$(this).val("something").change();
Setting the value of an expanding textarea fails to trigger any of the usual re-size callbacks. I added a
val
function to expanding textarea so that you can set it and have it resize itself after it was set.Usage:
Afterward you will notice that the textarea has expanded to show the full
val
.