F
F
Flipflap2020-10-02 14:55:30
1C-Bitrix
Flipflap, 2020-10-02 14:55:30

How to use JavaScript with Bitrix?

Hello. How to influence Bitrix elements using JS?

For example, I want to click on some object, let, for example, [SECTION_ID], take action.

The thing is that I want to do an action by clicking on a menu item, and it, the infection, does not have a standard html view so that I can refer to the class.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander, 2020-10-02
Madzhugin @Suntechnic

Flipflap , because you are making statements that are not true.
Why is this here:

there the menu is not laid out as a list in html, but is displayed in an array in php

?
If you do not understand how the menu is formed, it is better to ask how this happens.
Based on the php array, the menu component generates an html menu presentation block according to the template specified for this component.
You can add the classes you need either directly in the template (for all items) or modify the template so that it can be controlled by parameters from the PHP array to set different classes for different items.
You need to find a template based on which the menu is generated.
I would venture to suggest that it is somewhere there: /local/.default/components/bitrix/menu/...
But it is possible in another way - it all depends on who and how customized the site.

Z
ZardoZAntony, 2020-10-03
@ZardoZAntony

Read a free developer course for bitrix, at least what are templates and how to apply them.
Most likely, this will entail a lack of knowledge of js and php.
And no problem: copy the menu component template to your theme or to local/templates/.default/, . Change it to your liking. Add classes in your case.

A
Alexey Ukolov, 2020-10-02
@alexey-m-ukolov

You can either change the template to add custom classes or find the element through css selectors or through the content of the tag in javascript.

A
Anton, 2020-10-02
@anton99zel

JavaScript runs on the client in the browser with html elements. You want to act on the php array.
Wrap the php result with html elements and surround the js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question