This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
The data-request-update attribute doesn't work in component partial 'default.htm'. The partial doesn't update itself! I get only a page refresh. Why? This is my form and partial rendering in default.htm:
<form class="form-inline" data-request="onChangeResult" data-request-update="{{__SELF__}}::result: '#result-div'">
<input type="text" class="form-control" value="15" name="value">
<button type="submit" class="btn btn btn-primary">Calculate</button>
</form>
<div id="result-div">{% partial __SELF__~'::result' %}</div>
This is my code in result.htm (another partial in component partial directory, the same directory of default.htm):
<span class="result">{{ result }}</span>
Finally this is the function in component php file:
function onChangeResult() {
$value = post('value');
$this->page['result'] = $value;
}
What am I doing wrong? Maybe the reference to partial result.htm? Thanks!
UPDATE: the problem is the partial name {{ __SELF__ }}::result in data-request-update, but if i put only result, the partial isn't found. How can I reference component partial in default.htm? It is possible? If not, how can I do?
Last updated
I resolved putting the update inside the function onChangeResult():
function onChangeResult() {
$value = post('value');
$this->page['result'] = $value;
return ['#result-div' => $this->renderPartial('component::result')];
}
and I remove data-request-update attribute in form.
Last updated
For anyone who is still interest in using data-request-update
to update a partial, writing component::partial
inside the attribute worked for me, i.e.:
{{ form_ajax('onSearch', { update: { 'myComponent::myPartial': '#partial-element' } }) }}
I think you forget to pass a variable to partial view
{% partial SELF~'::result' result= result %}
wimalaya said:
I resolved putting the update inside the function onChangeResult():
function onChangeResult() { $value = post('value'); $this->page['result'] = $value; return ['#result-div' => $this->renderPartial('component::result')]; }
and I remove data-request-update attribute in form.
you have success ? I need help to do this ....
1-6 of 6