Change Attributes of the Node landing.block.updateattrs
We are still updating this page
Some data may be missing — we will complete it shortly.
Scope:
landingWho can execute the method: any user
The method landing.block.updateattrs changes the attributes of the block node. It returns true or an error.
Parameters
|
Method |
Description |
Available since |
|
lid |
Page identifier |
|
|
block |
Block identifier |
|
|
data |
Array of selectors and new values for data attributes. |
If the attribute pertains to a card (meaning it can have different content from card to card), the selector must be passed with a separator @:
data: {
'.container-fluid@1': {//the change will affect the attribute of the second card (counting from zero)
'data-test-checkbox': [1, 2, 3]
}
}
Types of Modifiable Content
Each type of attribute has its own format for saving. The examples provide default values for each type. The new value is passed in a similar format. For example, saving to an attribute of type image:
data: {
'.container-fluid': {
'data-test-image': {src: 'https://i.img.com/images/i/291626458734-0-1/s-l1000.jpg', alt: 666}
}
}
Specific notes for the checkbox and multiselect types: to save a new value, you must send the values of the selected elements:
data: {
'.container-fluid': {
'data-test-checkbox': [1, 2, 3]
}
}
Editing parameters of dynamic blocks is done through the method landing.block.updatenodes.
Examples
try
{
const response = await $b24.callMethod(
'landing.block.updateattrs',
{
lid: 313,
block: 6134,
data: {
'.bitrix24forms': {
'data-b24form': 'tratrata'
}
}
}
);
const result = response.getData().result;
console.info(result);
}
catch(error)
{
console.error(error);
}
try {
$response = $b24Service
->core
->call(
'landing.block.updateattrs',
[
'lid' => 313,
'block' => 6134,
'data' => [
'.bitrix24forms' => [
'data-b24form' => 'tratrata'
]
]
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
// Your required data processing logic
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error updating block attributes: ' . $e->getMessage();
}
BX24.callMethod(
'landing.block.updateattrs',
{
lid: 313,
block: 6134,
data: {
'.bitrix24forms': {
'data-b24form': 'tratrata'
}
}
},
function(result)
{
if(result.error())
{
console.error(result.error());
}
else
{
console.info(result.data());
}
}
);
How to Use Examples in Documentation