Im working in a Salesforce Community, using the Napili template. Im creating a vertical menu similar to:
Im trying to use slds tabs. I know I need to add the javascript to get the styling updates to work, when I change tabs. But out of all of the examples, I havent seen a simple enough one that makes sense to me.
I have jQuery loaded with ltng:require. It seems jQuery addClass/removeClass is the way to go. But I cant tell if I should use Renderer, or just put the jQuery in my js file?
I feel this should be very simple, but not having used jquery much before, and being new to Lightning components, Ive kinda hit a block.
The examples Ive seen seem convoluted and geared toward VF/Apex, and I want to do it the right way for LComponents. (renderer?) I feel it shouldn't be many lines of code, but may be underestimating the process. I would appreciate some direction if someone has the time.
<div class="slds-grid slds-grid--vertical slds-navigation-list--vertical">
<ul aura:id="libList">
<aura:iteration items="{!v.libraries}" var="lib" indexVar="index">
<li class="{!index == 0 ? 'fileSource_item slds-is-active' : 'fileSource_item'}">
<a class="slds-navigation-list--vertical__action slds-text-link--reset slds-truncate" href="javascript:void(0);" >
{!lib.Name} </a>
</li>
</aura:iteration>
</ul>
</div>
For reference, if anyone views this later >> Added my Helper that gets the data for Libraries. I added the '//New Line' to set the first records 'Selected' attribute to true.
getLibrariesForGrid: function(component, event, helper) {
var action = component.get("c.getSafeLibraries");
action.setCallback(this, function(data) {
component.set("v.libraries", data.getReturnValue());
//New Line below to set 'selected'
component.set("v.libraries[0].selected", true);
});
$A.enqueueAction(action);
}