I have a property editor that needs to know when the tab it is in is visible so it can draw it's control. Is there anyway I can detect this in the backoffice?
Hi Sam you could try injecting editorState into your property editor controller then use editorState.current.tabs, this is an array of tab objects with the current tab having its 'active' property set to true.
Hi sam can youshow what code you are using to poll? If you put a breakpoint in your controller and inspect editorState.current.tabs in your browser dev tools what is the 'active' value of each tab?
Hi Sam, it looks like whilst the active property value does change in the browser, for your purposes editorState does not get refreshed once injected into your controller so watching its values doesn't work. I don't know how you feel about this but this does seem to capture the tab change.
$('a[data-toggle="tab"]').on('shown', function (e) {
console.log('tab changed')
});
Detect tab change
Hello,
I have a property editor that needs to know when the tab it is in is visible so it can draw it's control. Is there anyway I can detect this in the backoffice?
Cheers, Sam
Hi Sam you could try injecting editorState into your property editor controller then use editorState.current.tabs, this is an array of tab objects with the current tab having its 'active' property set to true.
Thanks! This looked good but polling editorState.current.tabs doesn't seem to show the 'active' property ever being updated?
Hi sam can youshow what code you are using to poll? If you put a breakpoint in your controller and inspect editorState.current.tabs in your browser dev tools what is the 'active' value of each tab?
I was doing something like:
Polling:
Watching for change:
The active value stays set to true for the first tab, even once I have changed to the second tab.
Thanks, ok i'll do some tests later and see if there's a solution
Hi Sam, it looks like whilst the active property value does change in the browser, for your purposes editorState does not get refreshed once injected into your controller so watching its values doesn't work. I don't know how you feel about this but this does seem to capture the tab change.
It's not pretty, but it does work well enough for my use-case.
Thanks!
is working on a reply...