3.2.0

including Active Widgets objects in Ajax response.

I suspect this is a REALLY stupid question but i need to ask it anyway.

I am looking to purchase ActiveWidgets for use on a new website which will also use Ajax (using the prototype.js framework). I'm comfortable using the target.innerHTML = transport.responseText for 'normal' ajax responses based on HTML but what if i want to include (say) an Active Widgets grid in the ajax response. This is Javascript not HTML. I've tried include the <script>....</script> stuff but it seems to be ignored.

Can anyone tell me what i need to do.

many thanks...oh, and sorry for the stupid question....
Gazza
January 14,
<script> tags are NOT evaluated when you insert them via innerHTML. To run the script you have to extract the script and execute it with eval() function. There is a sample code in /examples/controls-tabs/code.htm
Alex (ActiveWidgets)
January 15,
alex thanks.

if i do this it seems to overwrite the whole page - not put the content inside the target tag (a <div> in this case).

I have read elsewhere that document.write causes problems when included as part of an ajax response so maybe that is the problem.
Gazza
January 16,
You can only use document.write() while the page is loading. Otherwise it creates a new blank document instead of the current one. In your case you should either use el.innerHTML=obj or add placeholder element with the same id and then call obj.refresh() (again, see the sample code in /examples/controls-tabs/code.htm).
Alex (ActiveWidgets)
January 17,
OK thanks - but to quote the example code for the combo widget....

new AW.UI.Combo;
obj.setId('myCombo');
obj.setControlText('Some text');
obj.setControlImage('favorites');
obj.setItemText(['Home', 'Favorites', 'Font size', 'Search']);
obj.setItemImage(['home', 'favorites', 'fontsize', 'search']);
obj.setItemCount(4);
document.write(obj);

....i guess that means that active widgets cannot be included in any ajax response.
Gazza
January 17,
You can include AW objects into ajax response - just don't use document.write() method. Check the sample code in /examples/controls-tabs/code.htm.
Alex (ActiveWidgets)
January 17,
Many thanks Alex. So in my ajax response buffer i should build up something like..

var names = ["Start", "Another page", "The last page"];
var values = ["page0.htm", "page2.htm", "page3.htm"];

var tabs = new AW.UI.Tabs;
tabs.setId("myTabs");
tabs.setItemText(names);
tabs.setItemValue(values); // store page URLs in the 'value' property.
tabs.setItemCount(3);
tabs.refresh();

and lets say i want to put this tab object inside a table cell with an id of 'theTabs' - what should i do in my Ajax 'OnSuccess' event to achieve this ?
Gazza
January 17,
You should assign a different id to the table cell, for example, myTabsParent, and then instead of document.write(tabs) use

document.getElementById("myTabsParent").innerHTML = tabs;

or,

you can insert a <span> into your html markup with the same id as your AW object and just call tabs.refresh();
Alex (ActiveWidgets)
January 17,
Alex,

I am not even doing creating AW widgets with AJAX response , I am just trying to create AW widgets after the page is loaded.

Even after refreshing every AW widget, I don't see the grid/buttons.
I just the text boxes and labels only

Thanks
Raj
February 21,

This topic is archived.

See also:


Back to support forum