• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Event handling from button on Form

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

  • Event handling from button on Form

    I have a Form defined as item on a Panel. I normally define buttons (Save, etc) on the toolbar of the Panel. So when you use fireEvent, the controller listens for event on Panel object. In this app, I'll have some buttons on the Form itself. When I use fireEvent, do I listen in controller on the Form or Panel that contains form? Sounds simple but can't find a forum hit anywhere matching what I'm trying to do. I'm not far enough along in this monster app to just try it and see, makes a difference how I design the form in the first place.

  • #2
    If you're using global controllers it shouldn't really matter. Can the post code for the view and controller in question so we can have a look?

    Comment


    • #3
      You can simply put an "itemId" on your save button. Suppose you called it "saveButton". Then your controller listens for the click event against "#saveButton"....no matter where the save button lives.
      Last edited by sean.lanktree; 04-05-2019, 09:01 AM.

      Comment


      • #4
        Richard, I'm curious, for learning purposes going forward, if you are referring to Sean's technique or you mean that the event will "bubble up" through the DOM from the Form to the Panel, so either could listen for it?

        No need for code, this is just standard MVC stuff where controller uses "this.control" to listen for events. I've always just used grids, panels, and itemId like Sean suggests. Disappointed I didn't think of that, that is best way for code clarity.

        This button triggers a lookup window where user can select a value to add to Form. A combo field won't work for this, need a grid on the store to show all the needed data and allow user to search/filter for what he is trying to select. And it can be used multiple times, our production process allows input units to be welded together to make one output unit. This is all long before the form will be actually submitted to server for update, that's done the traditional way with toolbar save/post button.

        Thanks guys, you were helpful as always!

        Comment

        Working...
        X