jeudi 13 avril 2017

How do I set a property of an Ember Component from another Component?

So I created part of this app that has a modal-window component that is supposed to open when you set the property enabled to true..

application.hbs has this:




In modal-window.js I have an action closeModal that does this.set('enabled',false) and likewise to open it, you set it to true.

There is a nav menu on the bottom of the app which uses different components help-link, admin-link, etc. admin-link is also a component with its own hbs and js file. This is how the app was designed. At the bottom of index.hbs:

  <div class="configs-list-footer">


<div class="logout-link">
  <a  class="tv-icon">
    <svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://ift.tt/nvqhV5" xmlns:xlink="http://ift.tt/PGV9lw"><g stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(1.000000, 1.000000)"><path d="M0.347826087,8 L10.7826087,8"></path><polyline id="Stroke-937" points="8 5.2173913 10.7826087 8 8 10.7826087"></polyline><path d="M1.03123478,4.83526957 C2.23471304,2.18831304 4.90253913,0.347617391 8.00027826,0.347617391 C12.2263652,0.347617391 15.6524522,3.77370435 15.6524522,7.9997913 C15.6524522,12.2258783 12.2263652,15.6519652 8.00027826,15.6519652 C4.88862609,15.6519652 2.21036522,13.7952696 1.01453913,11.1288348"></path></g></g></svg>
    <span>Logout</span>
  </a>
</div>

The action there calls an action in the admin-link.js file but there seems to be no way to tell modal-window to set enabled to true from OUTSIDE of itself which is a basic function of any program.

I cannot for the life of me after searching the Internet for hours figure out how to simply have the 'enabled' property of modal-window set to true when clicking on the admin-link component (which is basically an anchor tag)..

I have found out how to call an action from the Index route, but then just like with component to component I cannot figure out how to change the property of modal-window from the Index route.

Anytime anyone online asks how to do this they are met with "Components should be isolated and unaware of everything else" with no apparent way to do something so basic for a UI.

I'm using Ember 2.12.1




Aucun commentaire:

Enregistrer un commentaire