diff --git a/Docs/Delegators/Delegators.AddRemoveClass.md b/Docs/Delegators/Delegators.AddRemoveClass.md index 2c5e2ee..0570a9f 100644 --- a/Docs/Delegators/Delegators.AddRemoveClass.md +++ b/Docs/Delegators/Delegators.AddRemoveClass.md @@ -20,6 +20,7 @@ Toggles a Class on a specified element. ### Options * target - (*string*; optional) A selector for the element you wish to toggle the class. If not specified will change the class on the element itself. +* targets - (*string*; optional) A selector that returns multiple elements you wish to alter. Ignored if `target` is set. * class - (*string*; **required**) The class you wish to toggle. Delegator Trigger: addClass @@ -39,6 +40,7 @@ Adds a Class to a specified element. ### Options * target - (*string*; optional) A selector for the element you to which to add the class. If not specified will change the class on the element itself. +* targets - (*string*; optional) A selector that returns multiple elements you wish to alter. Ignored if `target` is set. * class - (*string*; **required**) The class you wish to add. Delegator Trigger: removeClass @@ -58,4 +60,5 @@ Removes a Class from a specified element. ### Options * target - (*string*; optional) A selector for the element you from which to remove the class. If not specified will change the class on the element itself. +* targets - (*string*; optional) A selector that returns multiple elements you wish to alter. Ignored if `target` is set. * class - (*string*; **required**) The class you wish to remove. \ No newline at end of file diff --git a/Source/Delegators/Delegator.AddRemoveClass.js b/Source/Delegators/Delegator.AddRemoveClass.js index 1f5d343..62771b6 100644 --- a/Source/Delegators/Delegator.AddRemoveClass.js +++ b/Source/Delegators/Delegator.AddRemoveClass.js @@ -18,10 +18,10 @@ name: Delegator.AddRemoveClass require: ['class'], handler: function(event, link, api){ var target = link; - if (api.get('target')) { - target = link.getElement(api.get('target')); - if (!target) api.fail('could not locate target element to ' + action + ' its class', link); - } + + if (api.get('target')) target = api.getElements('target') + else if (api.get('targets')) target = api.getElements('targets'); + target[action + 'Class'](api.get('class')); } };