JavaScript toggle sidebar when button in navbar is clicked in ember

I have two components:

{{pc-sidebar}}
{{pc-navbar action='toggleSidebar'}}

Inside pc-navbar, i have a button that i want toggle an sidebar--active class:

<button {{action 'toggle'}}>toggle sidebar</button>

and in the pc-navbar.js, i have the following:

  isOpen: true,
  actions: {
    toggle () {
        this.toggleProperty('isOpen');
        this.sendAction('action', this.get('isOpen'));
    }
  }

So.. the default value of sidebar is open, and when i click, i want switch for the next state.. true or false, depending on the previous state.

So.. i change the default value and send to my application controller:

  actions: {
    toggleSidebar (nextState) {
      console.log(nextState);
    }
  }

Now.. how can i grap the sidebar and toggle the class?? I'm a little lost here.. Am i doing this write?

In my pc-sidebar.js i have:

export default Ember.Component.extend({
  tagName: 'aside',
  classNames: ['sidebar', 'sidebar--active']
});

Thank you very much!!!

Answer:1

Assuming you use both the components in one route say aroute,You can have the property isOpen in aroute. You can pass this property to both the components, Then you can observe it in pc-sidebar if it was modified in pc-navbar.

Answer:2

I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-...

I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-...

  1. bundling failed error unable to resolve module
  2. bundling failed error fsevents unavailable
  3. bundling failed unable to resolve module
  4. bundling failed error while trying to resolve module

I am trying to change text so that they happen one at a time, almost in a consecutive looking way. columns.forEach((x) => { setTimeout(() => { x.style.color="red" }, 2500) }) ...

I am trying to change text so that they happen one at a time, almost in a consecutive looking way. columns.forEach((x) => { setTimeout(() => { x.style.color="red" }, 2500) }) ...

  1. asynchronous process callback

I have a data object that looks like this: var obj = { "one": null, "two": undefined, "three": [undefined], "four": "valid value" } And I need to end up with this: {...

I have a data object that looks like this: var obj = { "one": null, "two": undefined, "three": [undefined], "four": "valid value" } And I need to end up with this: {...

  1. lodash remove arrays
  2. lodash remove array element
  3. lodash remove array item
  4. lodash remove array index
  5. lodash remove array duplicates
  6. lodash remove array element by index
  7. lodash remove array element by value
  8. lodash remove array by value
  9. lodash remove array of objects
  10. lodash remove array item by value
  11. lodash remove array by key
  12. lodash remove array entry
  13. lodash array remove null
  14. lodash array remove undefined
  15. lodash array remove empty
  16. lodash array remove empty string
  17. lodash array remove method
  18. lodash array remove string
  19. lodash delete array element
  20. lodash delete array element by index

This is a pretty basic question. In electron, how do I check the url/filename of a BrowserWindow? let win; app.on('ready', () => { win = new BrowserWindow(); win.loadFile(path.join(...

This is a pretty basic question. In electron, how do I check the url/filename of a BrowserWindow? let win; app.on('ready', () => { win = new BrowserWindow(); win.loadFile(path.join(...

  1. browserwindow is not a constructor
  2. browserwindow.adddevtoolsextension
  3. browserwindow webcontents
  4. browserwindow events
  5. browserwindow preload
  6. browserwindow unresponsive
  7. browserwindowproxy
  8. browserwindow fullscreen
  9. browserwindow.addextension
  10. browserwindow.getallwindows()
  11. browserwindow id
  12. browserwindow session
  13. browserwindow is not defined
  14. browserwindow focus
  15. browserwindow options
  16. browserwindow title
  17. browserwindow.getfocusedwindow()
  18. browserwindow devtools
  19. browserwindow.webcontents.send
  20. browserwindow transparent