Documentation

landing.block.updateStyles

landing.block.updateStyles(lid, block,data)

The method updates block styles. Returns True or error.

Parameters

Parameter Description
lid Page ID
block Block ID
data The parameter passes key value array, where the selector is the key, and each value specifies two arrays:
  • classList - classes to be added into modifiable selector.
  • affect - pass the styles to be reset to zero for all child nodes. For example, a class is passed that paints a specific element (color). It means that an array [color] must be passed to 'affect', for the system to reset all 'color' for child nodes. Otherwise, the situation will be as follows: parent collar is red, and text inside will remain the same.

Selector can be passed without indicated position (for example, .landing-block-node-text), then all cards for this selector will be modified. The same goes for indicating a position (for example, .landing-block-node-text@2), then only the card at the specified position is modified (counting from zero).

Example

The example uses text-right - it is the right alignment class. That is why the 'affect' specifies that all the underlying text-align styles must be вудуеув.

Important! Such classes as landing-block-node-text are system classes in the manifest. If they are not passed, the class is lost, and a node cannot be modified via visual interface. Due considerations are required.

BX24.callMethod(
    'landing.block.updateStyles',
    {
        lid: 311,
        block: 6058,
        data: {
           '.landing-block-node-text': {
                  classList: ['landing-block-node-text', 'g-color-gray-light-v2', 'text-right'],
                  affect: ['text-align']
            }
        }
       },
    function(result)
    {
        if(result.error())
        {
            console.error(result.error());
        }
        else
        {
            console.info(result.data());
        }
    }
);


© «Bitrix24», 2001-2024