Page 1 of 1

Creating a new Element via JavaScript

Posted: Thu Jan 05, 2012 9:28 am
by esdaled
We are trying to add a button to a ProfoundUI screen (that is not running under Genie) via JavaScript. We were able to do this when the screen was running under Genie by using the following code:

Code: Select all

var newButton = newElement(12, 1, "input", "Trans. History");
newButton.id = 'btnTransHistory';
var newButton = getObj('btnTransHistory');
addEvent(newButton, "click", function(){
	riskTransactionHistory();
});
As newElement is Genie API, we have had to modify our code.

I have tried the following code, but the button does not display:

Code: Select all

var newButton = createNamedElement("button", "TransHistoryButton");
applyProperty(newButton,"id",'btnTransHistory');
applyProperty(newButton,"value",Trans. History');
applyProperty(newButton,"left",10);
applyProperty(newButton,"top",300);
newButton.onclick = function(){
	riskTransactionHistory();
};
Any suggestions on how to create a new Element in ProfoudUI?

Re: Creating a new Element via JavaScript

Posted: Thu Jan 05, 2012 12:31 pm
by Brian
We don't currently have a good way to accomplish this using JS in PUI. Is there a reason this must be done using JS and can't be controlled from your backend RPG? You could put the button on you screen and bind the "hidden" property so you could control it from RPG. Would this work for you?

Re: Creating a new Element via JavaScript

Posted: Thu Jan 05, 2012 2:42 pm
by esdaled
We could do it in the RPG, but it would be a lot quicker for us to do in the JS.

We would like the button to display on 30 different screens. So the JS detects that we are on one of those screens and adds the button. The onclick event on the button would not need to interact with the RPG as it displays a window with HTML data from an AJAX request based on the value of fields which are on all 30 screens.

If you will not be adding newElement type functionality to ProfoundUI, we will develop our own equivalent JS function.

Re: Creating a new Element via JavaScript

Posted: Thu Jan 05, 2012 5:51 pm
by Brian
It should not be difficult for us to implement the newElement function in Profound UI. I just wanted to ensure that it is what you needed before investing development time. Let me see if we can get this into the next release.

Re: Creating a new Element via JavaScript

Posted: Fri Jan 06, 2012 4:02 am
by Alex
For the next release of Profound UI, we will update the newElement() API to work with Profound UI Rich Display File applications.

You will be able to use it as follows:

Code: Select all

var newButton = newElement("button", "Trans. History");
newButton.style.left = "10px";
newButton.style.top = "300px";
addEvent(newButton, "click", function(){
   riskTransactionHistory();
});

Re: Creating a new Element via JavaScript

Posted: Fri Jan 06, 2012 9:35 am
by esdaled
Many thanks.