Hi Shelly,
Thanks for your help. I found another way to do it.
Set the list data type as dynamic and create the date variable.
Insert an setRowData function in the variables.
setRowData: function(catId){
var tmp=[];
var req = new XMLHttpRequest();
req.open('GET', ajaxHostUrl+'xxxxxxx.php?
categortID='+catId,true);
req.onreadystatechange = function (evt) {
/* readyState 4 indicates the transaction is complete;
status 200 indicates "OK" */
if (req.readyState == 4 && req.status == 200) {
data = eval(req.responseText);
product_category_sub_list_data._rowData = data;
document.getElementById
('product_category_sub_list').object.reloadData();
}
};
req.send(null);
},
Then the variable will looks like:
var product_category_sub_list_data = {
// Sample data for the content of the list.
// Your application may also fetch this data remotely via
XMLHttpRequest.
_rowData: [],
setRowData: function(catId){
var tmp=[];
var req = new XMLHttpRequest();
req.open('GET', ajaxHostUrl+'xxxxxxxx.php?
categortID='+catId,true);
req.onreadystatechange = function (evt) {
/* readyState 4 indicates the transaction is complete;
status 200 indicates "OK" */
if (req.readyState == 4 && req.status == 200) {
data = eval(req.responseText);
product_category_sub_list_data._rowData = data;
document.getElementById
('product_category_sub_list').object.reloadData();
}
};
req.send(null);
},
// The List calls this method to find out how many rows should be in
the list.
numberOfRows: function() {
return this._rowData.length;
},
// The List calls this method once for every row.
prepareRow: function(rowElement, rowIndex,
product_category_sub_list_row) {
// templateElements contains references to all elements that
have an
id in the template row.
// Ex: set the value of an element with id="label".
if
(product_category_sub_list_row.product_category_sub_list_label) {
product_category_sub_list_row.product_category_sub_list_label.innerText
= this._rowData[rowIndex].subcategoryTitle;
}
var self = this;
var handler = function(){
var this_data = self._rowData[rowIndex];
var browser = document.getElementById('browser').object;
product_list_list_data.setRowData
(this_data.subcategoryID);
browser.goForward(document.getElementById
('product_list'),this_data.subcategoryTitle);
};
// Assign a click event handler for the row.
rowElement.onclick = handler;
}
};
Finally, you can just call the setDataRow function to set ajax list
BRs
Felix
On Apr 10, 8:29 am, shelly <[email protected]> wrote:
> I don't use xmlhttprequests very often, I use a java backend. but this
> should work.
> // set handler for the loading data
> var onloadHandler = function() { xmlLoaded(xmlRequest); };
>
> // start the progress bar
> pi.style.visibility = 'visible';
>
> var xmlRequest = new XMLHttpRequest();
> xmlRequest.onload = onloadHandler;
> xmlRequest.open("GET", url);
> xmlRequest.setRequestHeader("Cache-Control", "no-cache");
> xmlRequest.send(null);
>
> function xmlLoaded(xmlRequest) {
> if (xmlRequest.readyState == 4 && xmlRequest.status ==
> 200) {
> // call the function to handle the response data
>
> var parkobj1 = eval(xmlRequest.responseText);
> cds=parkobj1;
>
> On Apr 8, 8:41 am,FelixJie Rong <[email protected]> wrote:
>
> > Hi all,
>
> > I am new to iphone web app development.
>
> > Does anyone know how to set set dynamic data for drilldown list's
> > _rowData?
>
> > I mean use ajax to set a list' _rowData. As it''s hard to set a return
> > from "onreadystatechange" and it's not very clear to Dashcode's load
> > function, I really need help on this issue.
>
> > Thanks in advance.
>
> >Felix
> > 8 April 2009
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---