How can I pass variables to a popup?

christomanos's Avatar

christomanos

16 Aug, 2010 09:05 AM

Hi all,

When I open a popup I want to pass some values to it. For example I have a list of products and when I click on them I need to show a popup with the product details. I manage to open and close the pop up and I use the way you suggest in the docs to mediate it. I don't know how to pass the product_id to the popup in order to populate it with data...

  1. 1 Posted by simon on 16 Aug, 2010 09:29 AM

    simon's Avatar

    The way I have handled this is to do the following in my command (params passed on the custom event):

    [Inject]
    public var event:ShowPopUpEvent;

    override public function execute():void
    {
    injector.mapValue(ShowPopUpEvent,event);
    createPopUpWindow();
    injector.unmap(ShowPopUpEvent);
    }

    protected function createPopUpWindow():void
    {
    var popUpWindow:PopUpWindow = new PopUpWindow();
    PopUpManager.addPopUp(popUpWindow, contextView, true);
    mediatorMap.createMediator(popUpWindow);
    }

    Which should make the event available in the Mediator.

    [Inject]
    public var event:ShowPopUpEvent;

    Cheers,

    Simon

  2. 2 Posted by Nikos on 16 Aug, 2010 09:47 AM

    Nikos 's Avatar

    I really don't like that work around sorry :)
    You should pass in your data to the pop up in the command

  3. 3 Posted by simon on 16 Aug, 2010 10:06 AM

    simon's Avatar

    > I really don't like that work around sorry :)

    Hah, no need to apologise ;-)

    Why do you think the data should be assigned to the popup in the command via property setting (just curious)? As opposed to simply ensuring the PopUp Mediator when registered has an Injection point defined to access this data?

  4. 4 Posted by Nikos on 16 Aug, 2010 10:16 AM

    Nikos 's Avatar

    After thinking further I actually prefer your approach simon

    Can't think of a better way to do it :)

  5. 5 Posted by christomanos on 18 Sep, 2010 07:25 PM

    christomanos's Avatar

    Thanks a lot simon. Works like a charm!

  6. Stray closed this discussion on 12 Feb, 2011 11:03 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac