2 Replies Latest reply on Apr 15, 2008 5:31 PM by artacus

    Form change notification

      It's pretty typical for apps to keep track of when a user makes a change to an item, then prompt the user if he tries to navigate away without saving.

      I have a form with about 20 data items. I want the parent form to watch for any changes made to its children. I don't want to add a change event listener for every form item. It looks like my change events should bubble to the parent container, but I haven't been able to get it working. Any help?

        • 1. Re: Form change notification
          jinx82002 Level 1
          Best practices method would be to have the form as a separate component, and have it listen for any changes made by the user, have it decide whether the form has been changed enough to notify the parent (or controller etc) and dispatch an event. So the parent would listen for only one event, but the form itself has to know what to do with it's 20 items, and when to notify other code.
          • 2. Re: Form change notification
            artacus Level 1
            That's pretty much what I'm trying to do. My question is what do I need to do to register the listener so that change events from below will be caught and handled by the parent form.

            I'm trying something like:
            myForm.addEventListener('change', myChangeHandler);

            But that is not working, so do I need to set the listener one TextInput at a time?
            myTextArea1.addEventListener('change', myChangeHandler);
            myTextArea2.addEventListener('change', myChangeHandler);