October: Ajax component in snippet not working

Created on 23 Jul 2019  路  2Comments  路  Source: octobercms/october

  • OctoberCMS Build: 455
  • PHP Version: 7.2
  • Database Engine: MariaDB
  • Plugins Installed: RainLab.Builder 1pilot RainLab.pages

Description:

Hi, i think i've found a mistake with partial inside a snippet.

I've made a partial, inside this partial i've put a component.
This partial is a snippet.

If i put this snippet inside a page (RainLab.Pages)
my component is displayed, but the ajax not working.

I've tried to put prefix on it, but still not working.
It's working well inside a page:

Steps To Reproduce:

Partial code:

<!-- Left Content -->
            <div class="col-md-9">
                <div class="pastobit-list"> 

                    {{ form_ajax('AvisDeces::onSearch') }}
                        <input type="text" name="search" class="" placeholder="Rechercher par nom et/ou pr茅nom">
                        <p></p>
                        <button type="submit" class="default-button">Rechercher</button>
                    {{form_close()}}
                <h2 id="h2_deces_en_cours" class="main-heading marbot20">Avis de deces en cours</h2>
                <br>

                {% component 'AvisDeces' %}
            </div>
        </div>

Screenshot of my partial CMS page:
Capture d鈥檈虂cran 2019-07-23 a虁 20 17 46

Inside the CMS Page, it's working fine.

Now, inside a page (RainLab.Pages plugin)

Capture d鈥檈虂cran 2019-07-23 a虁 20 19 33

My request not working:

Capture d鈥檈虂cran 2019-07-23 a虁 20 20 22

Thanks to you !

Question

Most helpful comment

Snippets, which is a sepcial kind of a partial, do not support AJAX handlers. This is documented here. Please note:

In general, component usage in partials is designed for basic components that render simple markup without much processing, such as a Like or Tweet button.

If you need more flexibility, consider registering a component as snippet. That should allow you to define ajax handlers.

All 2 comments

Snippets, which is a sepcial kind of a partial, do not support AJAX handlers. This is documented here. Please note:

In general, component usage in partials is designed for basic components that render simple markup without much processing, such as a Like or Tweet button.

If you need more flexibility, consider registering a component as snippet. That should allow you to define ajax handlers.

Thanks for this answers.
I've registered a page snippet an modify my component view. It's now working.

Was this page helpful?
0 / 5 - 0 ratings