This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

susana.o.santos29841
susana.o.santos29841

Hello I want to update two partials when a select change it's values. However I'm not being able to update my component's partials. When I call my partials on update the way the documentations teaches detalhes:'#agendaSelecionada' it returns an alert "the partial detalhes does not exists", and when I try to call as '_ SELF _::detalhes':'#agendaSelecionada' it returns "invalid partial name" (I've tryed several combinations of ", ~ and { on this line)

Can someone please help me on this?

This is my select and the partials with the default values

<div id='agendaSelecionada'>
  {% partial __SELF__ ~ '::detalhes' agendaSelecionada=__SELF__.agendaSelecionada %}
</div>

<div class="row" id='agendaSelect'>
  Local: 
  <select name="id_agenda" id="changeAgenda">
    {% for agenda in __SELF__.minhasAgendas %}
      <option value="{{ agenda.id }}">{{ agenda.titulo }} - {{ agenda.sede }}</option>
    {% endfor %}
  </select>
</div>

<div class='row' id="marcacao">
    {% partial __SELF__ ~ '::marcacao' 
        agendaSelecionada = __SELF__.agendaSelecionada
        ordemSemana = __SELF__.ordemSemana
        inicioDom = __SELF__.inicioDom
        atual = __SELF__.datas.atual
        prox = __SELF__.datas.prox
    %}
</div>

I call the handler using javascript

$('#changeAgenda').change(function(){
    $.request('onChangeAgenda',{
        data:{ id_agenda:$(this).val() },
        update:{
                detalhes:'#agendaSelecionada', 
                marcacao:'#marcacao'
        }
    });
});

And this is the event handler

    public function onChangeAgenda(){
        $id_agenda = input('id_agenda');
        $agendaSelecionada = minhasAgendas::find($id_agenda);

        $this->page['agendaSelecionada'] = $agendaSelecionada;
    }

Last updated

susana.o.santos29841
susana.o.santos29841

Found it for call a component partial I'm suppose to put an "@"

$('#changeAgenda').change(function(){
    $.request('onChangeAgenda',{
        data:{ id_agenda:$(this).val() },
        update:{
                '@detalhes':'#agendaSelecionada', 
                '@marcacao':'#marcacao'
        }
    });
});

Spent about 5hours looking for this and found it 1h after asking here. I hope this question helps someone in the future.

chris10207
chris10207

Thanks Susanna it does not work for me I am trying to update 2 partials as well after using an ajax request with the framework it looks like this:

$.request('sdOrderForm::onRemoveMenuSetToOrder', {
                data: menuObj,
                flash: 1,
                update: {
                    'sdOrderForm::order_summary_details': '#order-summary-details',
                    'sdOrderForm::order_summary_footer': '#order-summary-footer',
                },

the flash message is not displayed as well. I tried using the @ but it did change anything.

Any idea what is happening ?

chris10207
chris10207

oh ok got it, the update process is not executed if you have implemented the success method.

KVAnton.WEB
KVAnton.WEB

Thanks so much susana.o.santos29841!

<form data-request-update="'@something_partial': '#something_id'">

It works for me, and I didn't spend much time)

cleanse_
cleanse_

chris10207 said:

oh ok got it, the update process is not executed if you have implemented the success method.

<3 Love you. I couldn't figure out why it wasn't updating my view. Success method was the cause.

atm.it1117342
atm.it1117342

Thanks you >chris10207 said:

oh ok got it, the update process is not executed if you have implemented the success method.

So what do we do it we want to implement a loading overlay that should start before the request and end after it's completion?

pain-spark50564
pain-spark50564

KVAnton.WEB said:

Thanks so much susana.o.santos29841!

<form data-request-update="'@something_partial': '#something_id'">

It works for me, and I didn't spend much time)

@something_partial ?? Wanna mean : namefrommypartial ?

alexwenzel
alexwenzel

chris10207 said:

oh ok got it, the update process is not executed if you have implemented the success method.

thank you . too bad, its no where mentioned :P

Last updated

1-9 of 9

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.