jeudi 2 août 2018

Ember.js check if link object exists before executing

I was wondering how to check in ember.js that a link object exists before execution. It's mainly the ember component of this question that I'm confused on. I tried to combine ember.js and pure javascript and I'm not sure if looks right. I know types of this question has been asked a lot of times, but I couldn't find an ember example.

Here are some snippets:

.js file

  beforeModel() {
    const var url = this.get('#feedbackLink');
    if (typeof url === 'undefined') {
        analyticsStore.logMessage('OpinionLabFeedlinkUndefinedError', 'Opinionlab feedback link is undefined');
    }
}

.hbs file

<div class="feedback">
<a id="feedbackLink" target="_top" rel="nofollow" role="button" onclick="OpinionLab.O_LC();return false;"
    <strong>
        <span class="secondary">
            <span class="feedback">Submit your feedback!</span>
        </span>
    </strong>
</a>
</div>

Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire