I have a ui:inputCheckbox:
<ui:inputCheckbox value="{!v.bool}" change="{!c.toggle}" />
Even if I remove the change
attribute, when I click on the checkbox (note: it's a toggle, not sure if that matters) the toggle will very briefly, for less than a second appear as active and will then immediately jump back to inactive (as defined by the bool
attribute).
Since the bool attribute is never changing from false I would expect the checkbox to not jump between the inactive and active states when clicked.
Is there some way to enforce this as I think the value jumping like that does not look good.
Component:
<aura:attribute name="valueToSetBool" type="String" default="inactive" />
<aura:handler name="change" value="{!v.record.socialsuite__Status__c}" action="{!c.updater}"/>
<aura:attribute name="bool" type="Boolean" default="false" />
<div class="slds-grid">
<div class="slds-size_1-of-8 slds-row">
<div class="slds-form-element">
<label class="slds-checkbox_toggle slds-grid">
<span class="slds-form-element__label slds-m-bottom_none slds-m-left_x-small">Active:</span>
<ui:inputCheckbox value="{!v.bool}"/>
<span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
<span class="slds-checkbox_faux"></span>
<span class="slds-checkbox_on">Active</span>
<span class="slds-checkbox_off">Inactive</span>
</span>
</label>
</div>
</div>
</div>
Controller:
updater : function(component) {
component.set("v.bool", false);
}
stringAttr == 'textIWantToDisplayAsActive'
but that doesn't bind the variable. So this is why I have this 'updater' controller function, as a kind of fake binding for my real attribute to the booleanAttribute. It's basically just if attr = 'text`' attrBool = true, if attr = 'text2' attrBool = false – Aequitas Jan 29 '18 at 22:34