1

Closed

Access input data

description

Hey,

I added a select control to the pop up.
 Alert.show("Open document",
                "<select id='selectBox'><option value='0'>Document_1</option><option value='1'>Document_2</option></select>",
                [
                    new Alert.Button("Open", function() { return _this.openSelectedDocument(), true),
                    new Alert.Button("Cancel")
                ]);
When I try to access the selectd value in the openSelectedDocument function like
$("#selectBox").val(); 
I get 'undefined' returned. I do not get the problem, because the select control is already rendered to the DOM and the force the pop up to stay open (preventClose is true).

Is there any other "scope" or something?
Closed Feb 6 at 8:48 PM by Liger_cp <SND\Liger_cp>

comments

Liger wrote Feb 6 at 7:58 PM

Hi,

The alert.js wrapper sits outside the CRM frame, so jquery won't be able to find the elements.

You should be able to use Alert.$("#selectBox").val(); to give you context to the top document where alert.js sits.

However, I'd recommend using a web resource to hold all your HTML etc, and use Alert.showWebResource() to display it, then you can use the Alert.getIFrameWindow() function to get context of the frame, to access custom controls etc.

Hope that helps,
Paul

babyjesus wrote Feb 6 at 8:32 PM

Thank you!
That did the job! I will give the showWebResource approach a try. Maybe it could be documented a bit more detailed.

Thanks,
Tom

Liger wrote Feb 6 at 8:48 PM

No problem, there is some documentation on showing web resources here:
https://alertjs.codeplex.com/documentation#Alert.showWebResource

And for accessing the iframe values here: https://alertjs.codeplex.com/documentation#Alert.getIFrameWindow

Hope that helps,
Paul

wrote Feb 6 at 8:48 PM