0

In a lightning component, I have a picklist that display some Article__c. In the controller js I can get the value of the selected Article__c like this :

In the component :

<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<aura:registerEvent name="articleDetail" type="c:Z_ArticleToDetailEvent"/>

<ui:inputSelect change="{!c.onArticleChange}" aura:id="selectedArticle" >
    <aura:iteration items="{!v.lstArticles}" var="article">
        <ui:inputSelectOption label="{!article.Name}" text="{!article.Id}" />
    </aura:iteration>
</ui:inputSelect>

In the controller js :

var selectedArticle = component.find('selectedArticle').get("v.value");

But I'd like to transform this picklist into a common list like that :

<aura:iteration items="{!v.lstArticles}" var="article">
            <li class="list-group-item">
                    <a onClick="{!c.onArticleChange}" aura:id="selectedArticle" >
                            <p>{!article.Name}</p>
                            <p>{!article.Prix__c}</p>
                    </a>
            </li>
    </aura:iteration>

And the problem is that in the controller I cant use the get("v.value") on the element (I get a javascript error). So I search a way to get the value of the Article__c I click. After the click on the object, I display it in another component, and for that I use an event like that :

<aura:event type="APPLICATION">
<aura:attribute name="article" type="Article__c"/>

So I need to get the value of the object.

Thanks

  • @Praveen Unfortunately that subject doesn't answer my question, beacause I am not able to display the id of the Article into another component. – dou Oct 3 '16 at 7:46
  • Just to display the selectedArticle detail, you don't need a separate component(if the fields are few).you could have data-index to store the index instead of recordid as mentioned here – Praveen Oct 3 '16 at 13:05
0

"lstArticles" should be attribute of the component

<aura:attribute name="lstArticles" type="Article__c[]"/>

Not the answer you're looking for? Browse other questions tagged or ask your own question.