CRecordWebRemoveClassesFromElement

The message CRecordWebRemoveClassesFromElement removes one or more classes from an HTML element.

The message is part of the RemoteSkin Web API.
The API is located in the plugin NY_RemoteSkinWebProtocolAPI.

{
  "id": "8fffd143-dab3-4f96-ac64-6f660bf45cfd",
  "name": "WEB_REMOVE_CLASSES_FROM_ELEMENT",
  "description": "Remove classes from an HTML element.",
  "slots": [
    {
      "key": "1",
      "name": "SELECTOR",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The selector."
    },
    {
      "key": "2",
      "name": "CLASS",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The class to remove."
    },
    {
      "key": "3",
      "name": "CLASSES",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING_ARRAY",
      "description": "The classes to remove."
    }
  ]
}

Arguments

  • SELECTOR : The selector is used to find the HTML elements to be changed.
    Example: ".example". Find more examples here
  • CLASS: Use this parameter if you are only removing one class.
  • CLASSES: Use this parameter if you are removing more than one class.

Usage with the helper class CWebApi

The easiest way is to call the corresponding method in the CWebApi class. The use of the class is described there.

mWebApi.removeClassFromElement(@NotNull final String aSelector,
                               @NotNull final String aClass);
mWebApi.removeClassesFromElement(@NotNull final String aSelector,
                                 @NotNull final Collection<String> aClasses);

Usage as message

The RemoteSkin target address is also required.

public void removeClassesFromElement(@NotNull final CTargetAddress aRemoteSkinAddress,
                                     @NotNull final String aSelector,
                                     @NotNull final String[] aClasses) throws CException
{
    // Envelope
    final CEnvelope env = CEnvelope.forSingleTarget(mRemoteSkinAddress);
    
    // Record
    final CRecord record = CRecordWebRemoveClassesFromElement.create();
    CRecordWebRemoveClassesFromElement.setSelector(record,
                                                   aSelector);
    CRecordWebRemoveClassesFromElement.setClasses(record,
                                                  aClasses);
    
    // send message
    sendNotification(env,
                     record);
}

See also: