#3647 - Block AJAX loading
| Identifier | #3647 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Block AJAX loading |
| Status | Completed |
| Handling member | Salman |
| Addon | General / Uncategorised |
| Description | I have merged in my staff actions block changes (Admin Zone dashboard). However, the AJAX browsing isn't working.
Changing the filters should work dynamically. It's doing: $dom.trigger(el, 'submit'); (In v10 this would have been calling onsubmit(), but I think you're likely using proper event listeners now). Pagination should also work via AJAX. I suspect your AJAX block reload code is broken and this is highlighting it. |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
1. Many calls to $dom.internaliseAjaxBlockWrapperLinks() had a wrong parameter name, sorry about this :(.
2. After fixing above, the "internalising" was only working once because when new HTML was loaded via AJAX, $dom.internaliseAjaxBlockWrapperLinks() wasn't getting called afterwards to attach event listeners to the new links and forms. This is because we got rid of inline <script> tags, we now use "behaviors" instead which are applied any time new HTML is inserted using $dom.* functions. They are called on an element using data attributes. So I added a behavior named [data-ajaxify-links] to fix this.
3. The on-change event listeners attached for triggering the form submit event were also lost when loading new HTML, this is where event delegation shines. I simply added a 'js-onchange-submit-form' class to the relevant elements and added this to the template function: $dom.on(container, 'change', '.js-onchange-submit-form', function (e, el) { $dom.trigger(el.form, 'submit'); });.
4. The submit event needed to be triggered on the form, not the input elements: $dom.trigger(el, 'submit'); -> $dom.trigger(el.form, 'submit');
So the main_staff_actions block is working now but other stuff using $dom.internaliseAjaxBlockWrapperLinks() is probably broken as well :(, testing/fixing that now.