Issue #1198Opened June 13, 2018by krunal0390 reactions

QUESTIONS : Find element in Model

Question

Code SnippetTEXT
I have custom component and it render below html, I want to update value of h4 tilte and other element on trait changed, but not sure how can I find h4 and other element in model (NOT in view) and change value via trait change. I have used below approach but does not want to access model via index.
`updateTitle : function updateTitle() {
                    var title = this.get('title');
                    var linkModel = this.get("components").at(0);
                    if (linkModel) {
                        var titleContainer = linkModel.get("components").at(3);
                        if (titleContainer) {
                            var h4 = titleContainer.get("components").at(0);
                            if (h4) {
                                h4.set("content", title);
                            }
                        }
                        linkModel.attributes.attributes["aria-label"] = title;
                        linkModel.attributes.attributes["title"] = title;
                    }
                    this.set("data-title", title);
                    if (this.get('isCreatePage') && this.changed && this.changed.title) {
                        this.set('isPageCreated', false);
                        this.set('bespokePageUrl', '');
                        this.updateIsCreatePage();
                    }
                }`

![image](https://user-images.githubusercontent.com/11716808/41340023-4902ed16-6eee-11e8-9f70-7332ada6c7ff.png)

Answers (2)

lock[bot]September 17, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.