Hide/show placeholder (instead of remove/append)
p1gtr opened this issue · comments
Currently tagEditor removes the placeholder when hiding it, and re-initiate it when showing it. This makes it impossible to dynamically change the placeholder text (set_placeholder()
would reset it every time).
This fiddle shows a solution. I mark all changed code with keyword "TagEditorHack" so just search for it.
Changes needed:
- change
set_placeholder()
so it only append the placeholder once. - change all
$('.placeholder', ed).remove()
to$('.placeholder', ed).hide()
- somehow the changes above cause a racing condition where when you delete a tag, the placeholder would appear before the animation of tag deletion completes. So we also need to change
update_globals()
so that it only callsset_placeholder()
during initialization.