Announcement

Collapse
No announcement yet.

webapp javascript how to get reference to other view

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • webapp javascript how to get reference to other view

    If I want to use the quickCreate method from views/site/navbar in another view or from f12 console is there a way to get a reference to the existing view?

  • #2
    I don't know any proper way to do it. You can try to simulate a 'click' event on a DOM element.

    Comment


    • #3
      I propose as a new feature to have an externally-accessible object that exposes the current view and model graph. so for example one would do something like assigning callbacks for other js libraries.

      Other than that maybe assigning the app object to window instead of keeping it in anonymous scope could be a way to interact with it and obtain properly references.

      Comment


      • #4
        One of the problems that sparked my question is this: I extended the 'setup' method of 'views/detail' for Call scope to add a button to the menu if a custom field is set to true. I am working on updating after the entity is saved by using the listenTo('after:save'). It works mostly, but I see that some times the data is not yet loaded (this.model.attributes.myField is undefined, but it is true in the database). How can I wait from the extended setup method the loading of the model?
        Last edited by tothewine; 06-03-2020, 06:22 PM.

        Comment


        • yuri
          yuri commented
          Editing a comment
          I don't understand. This should work:

          this.listenTo(this.model, 'sync', function () {

          }, this);

        • yuri
          yuri commented
          Editing a comment
          If the record is updated by some action made in another place (out of the current form) or made by another user, I'd recommend using websocket. It refreshes the model once the record is changed at backend. Out-of-the-box.

      • #5
        No. It would be a bad design choise. Views should not communicate with far parent views, or even not parent. It will promote writing a messy logic.

        Comment

        Working...
        X