Attribute manager
++ This article assumes at least basic knowledge at CSS. +
++ In Inter's universe, with the attributes manager + we are able to perform these stuffs in a reactive and elegant way: + +
+ +-
+
- + To create one or several attributes. + +
- + To update the value of one or several attributes. + +
- + To delete one or several attributes. + +
+ To set an attributes manager in an element, we use this syntax {...managerName} +
++ The above syntax must be the only attribute of the target element and to parse + the template searching for the managers, we use the toAttrs + function, and the referred function recieves only an object as its argument, and its properties + must be in which will indicate the value of id attribute of the root element where + the elements that got the managers can be found, and other acceptable property is data, + guess its goal? That's it! the data property must be a plain Javascript object, whose + its properties will be the names of the managers, and its values will be an object whose its properties will + be the names of the attributes/events that will be attached in the element where the referred manager was found. + +
+ +The manager object
++The toAttrs function returns an object +with the same properties as the data object and +in privious example, we destructed the referred object to take out the object manager +photo, if you open up the browser console right now in this page +and try to change the value of one of the properties of the photo +object, you'll see the interface changing to reflect the new value. And when the property +of an oject manager is the name of an event, for instance the onclick event, +Inside the body function attached to the event, this will +be the object manager. +
++To delete an attribute with the manager, we just have to set it as +null +
+ ++The manager name must be always in lowercase, and one manager only controls +an element, if you try to set a manager to multiple elements, only the first one +will be controled. If you're not willing to use an attribute yet, just set it to +null, and it won't be created till you define another value to it. + +
+ + +The observe method
++ This method became available since: v2.1.0
++It will be a method from the object manager, it only accepts a function as its argument, +and the referred function will be called every single time a property's value change, will +be called with two arguments: +
+-
+
- + The first argument will indicate the property name. + +
- + The second argument (the last) will indicate the new property value. + + +
The setAttrs property
++It will be a property from the object manager, it will +be used to update the value of multiple attributes(like setRefs from reference). +It only recieve an oject as its value, the properties of the referred object +must indicate the attributes names whose their values will be updated, and the values +of those properties will be new values of the each attribute.
+ ++Try to click the photo and see what happen. This article explained to you everything +about the attributes manager. +
+ +