Avoid Sheet Re-render When Editing Actor's Item

TL;DR How do I avoid a re-render of a character sheet with actor.items displayed, that happens when item.update is called? I have a simple on event handler on my character sheet like this:
onUpdateItem(event) {
const { itemId, updateItem } = event.currentTarget.dataset
const item = this.actor.items.get(itemId)
item.update({ [updateItem]: event.target.value })
}
onUpdateItem(event) {
const { itemId, updateItem } = event.currentTarget.dataset
const item = this.actor.items.get(itemId)
item.update({ [updateItem]: event.target.value })
}
with a supporting template (a partial of the character sheet that displays all the items in a table) like so:
<input
type="number"
name="item.system.weight"
data-dtype="Number"
data-item-id="{{item._id}}"
data-update-item="system.weight"
value="{{item.system.weight}}"
/>
<input
type="number"
name="item.system.weight"
data-dtype="Number"
data-item-id="{{item._id}}"
data-update-item="system.weight"
value="{{item.system.weight}}"
/>
and of course an event handler tied in activateListeners (with super.activateListeners(html)):
html.find('input[data-update-item]').change(this.onUpdateItem.bind(this))
html.find('input[data-update-item]').change(this.onUpdateItem.bind(this))
I'm trying to avoid a re-render that happens when item.update is called in my character sheet class code. It's bothersome because I would like the fields to be tab-targetable (clicking tab switches user-input to the next input in line), however that focus is lost due to the re-render.
No description
3 Replies
Zhell🎄
Zhell🎄•11mo ago
onUpdateItem(event) {
const { itemId, updateItem } = event.currentTarget.dataset
const item = this.actor.items.get(itemId)
item.update({ [updateItem]: event.target.value }, {render: false});
}
onUpdateItem(event) {
const { itemId, updateItem } = event.currentTarget.dataset
const item = this.actor.items.get(itemId)
item.update({ [updateItem]: event.target.value }, {render: false});
}
this will also cause the item sheet to not re-render, however.
martinAbsolute
martinAbsoluteOP•11mo ago
@Zhell Yep that did it, thank you v much!
Leo The League Lion
Leo The League Lion•11mo ago
@martinAbsolute gave vote LeaguePoints™ to @Zhell (#44 • 64)
Want results from more Discord servers?
Add your server