I've got a task list app where tasks are displayed by category.
I have the categories listed in two places. I'm allowing the category name to be edited in-place using the best_in_place gem. I have that working fine. My issue is that since I have the category name in two places and I'm only editing one occurrence of it in-place, I need the other appearance of the name that was not edited to be updated with the new name after the form submits. What would be the best way to refresh/reload the affected category's name?
Thanks.
You need to use a callback.
Using the description of the gem (https://github.com/bernat/best_in_place) i got this:
So in your case you need to do something like that:
If you have this code (haml)
You do need a callback. However, in the context of the callback handler, 'this' represents the element the call was made from, so you could just do
and get the new value to the other widget that way. The event in the call back handler also has currentTarget as a property, which is the widget that started the ajax request. However, I don't think that's needed.