Answer the question
In order to leave comments, you need to log in
How to sort AJAX products in Bitrix without using the ajax setting for the catalog component?
Now sorting works on the basis of GET parameters with page reload, I made a script that does sorting using the jquery.load method, that is, products are pulled to the page by following the url with get parameters, while the page is not reloaded.
The problem is that after such an Ajax loading, the scripts on the cards in the list do not work, that is, the quantity selection and the buy button do not work ...
Is there another way to do Ajax sorting in Bitrix or maybe someone knows what js function can be run after Ajax is completed to update scripts for cards?
Answer the question
In order to leave comments, you need to log in
In section.php you need to do RestartBuffer
In ajax response
var ob = BX.processHTML(data);
BX.ajax.processScripts(ob.SCRIPT);
The problem is that after such an Ajax loading, the scripts on the cards in the list do not work, that is, the quantity selection and the purchase button do not work...
if an event is hung on an element, then it is hung on an existing element, and does not work on a newly loaded via ajax, you need to hang the event on a static parent element or the entire document.
$({parent element}).on({event},{event element},function(event){...});
If you hang on the document, you must take into account that all the specified elements will be processed, if on the parent element, then only those elements that are inside the parent element are processed.
In this version, events will work on new objects loaded by ajax.
It is easier to transfer sorting and other parameters by POST, it is at least more convenient, especially when you take into account filtering and pagination in processing (I think you will encounter this in the future)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question