A
A
Alexander2020-01-15 16:41:51
1C-Bitrix
Alexander, 2020-01-15 16:41:51

How to properly edit scripts built into Bitrix JS?

I placed the component on the page, copied the built-in template to fix it, and ran into a problem:
I need to change the block width, but it is calculated in the component script /bitrix/components/bitrix/search.title/script.js
If I change it, then on a subsequent update, it may change and my template will break.
In other components, this script usually lies in the template.
What is the right thing to do in this case?
Copy this file to the template and include it in the template? And how then to disable the built-in script?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail, 2020-01-15
@RuComMarket

as an option:
copy the component to /local/components/,
rename it
, edit it as you need
and call it in the right place
in this option, it will be like your own component based on the standard one, and it will not crash when updated.

P
PetrPo, 2020-01-15
@PetrPo

Copy this file to the template and include it in the template? And how then to disable the built-in script?

1. Copy - yes, it will connect itself (if it will be called script.js),
2. Disable built-in - no, functions can be redefined in javascript. Because connection - component->component template, your function with the same name will override the built-in one.
Another option, if you don't want to redefine - instead of redefining the function, you change its name, this function is called in template.php, you also change the name there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question