7

I'm implementing a GUI Extension for Audience Manager - initial steps have gone well, got my config right, script loaded etc.

I'm looking for the event I can subscribe to when the "Details" tab is clicked.

$evt.addEventHandler($display, "????", onSelectTabControl);

function onSelectTabControl () {          
}

I want to manipulate some extended details fields so need to make sure this tab is selected before I start grab fields.

UPDATE

Playing through Chrome's console when I open a Contact I can get the tab strip through:

var tabs = $display.getView().properties.controls.TabControl;

And can then detect a selection with:

tabs.addEventListener("select", function(t) { console.log(t); });

When I add these to my inserted script though I start seeing an error????

Uncaught Error: Value should be a function.

UPDATE 2

Got this working with the following code and following Albert's article as Dave mentions below. I hadn't realised that the start event was still called when the Contact View was displayed:

$evt.addEventHandler($display, "start", onDisplayStarted);

function onDisplayStarted() {
    console.log("OnDisplayStarted called");
    $evt.removeEventHandler($display, "start", onDisplayStarted);

    var tabs = $display.getView().properties.controls.TabControl;
    if(tabs!==undefined){
        tabs.addEventListener("select", function(t) { 
            console.log(t); 

            if(t.data.element.id == "DetailsTab") {
                console.log("DetailsTab!");

                // Set and fields to disabled
                $j(t.data.element).find(":input").attr('disabled','disabled');
                // Turn off any date buttons
                $j(t.data.element).find("div.button").hide();
            }
        });
    };
}

What I could do with now is a way to check which Address Book a contact is in from the Contact View - something I'm not sure is possible but a topic for a different question!

3
  • Hi Neil, I've been working on a GUI extension for a different purpose. When I add the above code to my _isAvailable method, and am on a page with tabs it works fine (I don't have Audience Manager on my dev box, so can't test there) Could you share the code you are adding the above to? Jun 3, 2013 at 14:11
  • Cheers Dave - is you GUI extension a command or button? I just want a script to run when the Detail tab is activated in the ContactView. Didnt think I needed all the isEnabled, isAvailable stuff.
    – Neil
    Jun 4, 2013 at 12:05
  • It was on a command, as thats what i had open at the time! I just wanted to check the JS worked ok. You're right, you shouldn't need _isEnabled etc for what you are doing. I've adapted a blog post by Albert Romkes in an answer below, let me know if that works! Jun 4, 2013 at 15:14

1 Answer 1

3

Using Albert's post here, i've managed to get an example working.

To an existing Gui Extension I added the config below:

<cfg:group name="GroupName">
    <cfg:domainmodel name="Name">
        <cfg:fileset>
            <cfg:file type="script" id="Id">/client/js-test.js</cfg:file>
        </cfg:fileset>
        <cfg:services />
    </cfg:domainmodel>
</cfg:group>

Then the JS file is just:

$evt.addEventHandler($display, "start", onDisplayStarted);

function onDisplayStarted() {
    console.log("OnDisplayStarted called");
    $evt.removeEventHandler($display, "start", onDisplayStarted);

    var tabs = $display.getView().properties.controls.TabControl;
    if(tabs!==undefined){
        tabs.addEventListener("select", function(t) { console.log(t); });
    };
}

Obviously you'll need to adapt this for your needs, but it should get you started.

2
  • Thanks Dave - I had started with Alberts article myself, but if you check the comments, Boris mentions there'a a better way to target your script for a specific view - which is what I did. Let me try a quick double check that I didn't cock something obvious up .....
    – Neil
    Jun 4, 2013 at 18:22
  • Thanks Neil - I hadn't seen that, seems like a better solution. Post your code when you get it working! Jun 4, 2013 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.