Skip to content

Working with JavaScript

September 4, 2007

When you are working on JavaScript UI libraries, or any code that creates dynamic user-interface elements, there are 3 primary ways for clients to work with your JavaScript.

1. You can have your expect the client to provide you with the ID of the element to render in.
2. You can output the controls directly onto the page using some for of document.write().
3. You can have a server side control output the JavaScript for you.

Example of 1:

var tree;
function treeInit() {
tree = new YAHOO.widget.TreeView("treeDiv1");
var root = tree.getRoot();
var tmpNode = new YAHOO.widget.TextNode("mylabel1", root, false);
var tmpNode2 = new YAHOO.widget.TextNode("mylabel1-1", tmpNode, false);

Example of 2: ActiveWidgets

// create ActiveWidgets component
var obj = new AW.UI.Button;
// set the display text
obj.setControlText("Click me");
// assign click event handler
obj.onControlClicked = function(){
this.setControlText("Hello World!");
// add component to the page


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: