emojionearea
emojionearea copied to clipboard
Reset input field after ajax complete
Sorry for my English!
Hi, I have a problem. I initialize plugin after page load. Open modal window, type some text in field with emoji, than I pick emoji and send it to the server. If response code 200, I want to reset all the fields. If I type this
$('#some_form').trigger('reset')
this will work for every input exept emojione.
So I going to do next thing
var emojioneAreas = $(".em").emojioneArea(); emojioneAreas.data("emojioneArea").setText('');
And field is reset but, the content of this field don't present in new FormData object. So tell me pleas, how can I send date via ajax, reset all inputs in form, and fill the form again, without any pain.
emojioneAreas.data("emojioneArea").setText('');
should reset your input,
I don't know how works your form, but probably you should create new FormData()
after emojioneAreas.data("emojioneArea").setText('');
emojioneAreas.data("emojioneArea").setText('');
should reset your input, I don't know how works your form, but probably you should createnew FormData()
afteremojioneAreas.data("emojioneArea").setText('');
I bind submit event and my FormData created every time submit event is triggered.
So firstly I create new FormData and send it via ajax. If ajax response 200, I am going to emojioneAreas.data("emojioneArea").setText('');
and this $('#some_form').trigger('reset')
after all this steps done form is reset and it's looks like everything ok, but when I fill the form again, new FormData object don't have input with .em class, which is initialized by emojioneArea.
Why not just append the emojiOneAreas to your FormData manually using formData.append?
Why not just append the emojiOneAreas to your FormData manually using formData.append?
I think about it, and probably I will go this way. But it's would be cool to have cleaner way to fill formdata object