I think if I check the active state right before I do the return it will work. Didn't know this would be that easy. I already have an ApplicationStateProxy I am using.
Background: I am using Haxe PureMVC with State Machine to build a web application (deployed to JavaScript). I am integrating it with a government-mandated UI framework that uses a JQuery-powered tabbed interface. The application has 4 tabs and I have created an application state for each of these tabs. The tab interface (EasyTabs) has a built-in event system which helps the integration. Clicking a tab fires an event, and if the handler for the event (in my Haxe app) returns true, only then will the tab view change.
Problem: I want that handler to send a StateMachine.CHANGE notification and let the "Entering" command for the next tab state to do the necessary checks that ultimately cancel or approve the state transition. I'm just not sure how to send the notification and use the results of that action to return true or false so that EasyTabs gets the Boolean it requires.
Here's my current code:
:
var tabs=new JQuery("#theTabs"); tabs.bind("easytabs:before",tabHooksHandler); //setup the handler for the tab event
private function tabHooksHandler(e:Dynamic,clicked:Dynamic,targetPanel:Dynamic,settings:Dynamic):Bool{ switch(targetPanel.selector){ case"#tab1": sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_FILE ); case"#tab2": sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_TREES ); case"#tab3": sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_MAP ); case"#tab4": sendNotification ( StateMachine.ACTION, null, Main.ACTION_GOTO_CALCULATOR ); } return true; //this lets EasyTabs complete the switch of tabs. If the StateMachine does a cancel, I would want this to return false. } So, could I use a callback somehow? Suggestions would be appreciated, thanks!