Hi, given is the following component code:
{% set itemList = __SELF__.itemList %}
{% for item in itemList %}
<div id="item-{{ item.id }}">
{% partial __SELF__ ~ "::oneItem" item=item %}
</div>
{% endfor %}
And the coressponding partial to render a single item:
<span>{{ item.title }}</span>
<button type="button"
data-request="onChangeTitleOfOneItem"
data-request-data="id: {{ item.id }}"
data-request-update="'@oneItem': '#item-{{ item.id}}'">
Now the problem is, that i do not know how to return the changed item to the partial. The following code does not work.
public function onChangeTitleOfOneItem() {
$id = post('id');
$item = Item::find($id);
$item->title = "Change title for testing purpose";
return $item;
}
There is no error message, but the title won't update. Any ideas?
Thanks, Joachim