| 1 |
define(["dojo/_base/lang"], function(lang){ |
| 2 |
var _onResults = []; |
| 3 |
|
| 4 |
return { |
| 5 |
|
| 6 |
setDetailsContext: function(index, e, params){ |
| 7 |
if(params){ |
| 8 |
params.cursor = index; |
| 9 |
}else{ |
| 10 |
params = {"cursor":index}; |
| 11 |
} |
| 12 |
|
| 13 |
var transOpts = { |
| 14 |
title : "itemDetails", |
| 15 |
target : "itemDetails", |
| 16 |
url : "#itemDetails", |
| 17 |
params : params |
| 18 |
}; |
| 19 |
this.app.transitionToView(e.target,transOpts,e); |
| 20 |
|
| 21 |
|
| 22 |
}, |
| 23 |
|
| 24 |
|
| 25 |
insertResult: function(index, e){ |
| 26 |
if(index<0 || index>this.list.store.data.length){ |
| 27 |
throw Error("index out of data model."); |
| 28 |
} |
| 29 |
if((this.list.store.data[index-1].First=="") || |
| 30 |
(this.list.store.data[index] && (this.list.store.data[index].First == ""))){ |
| 31 |
return; |
| 32 |
} |
| 33 |
var data = {id:Math.random(), "label": "", "rightIcon":"mblDomButtonBlueCircleArrow", "First": "", "Last": "", "Location": "CA", "Office": "", "Email": "", "Tel": "", "Fax": ""}; |
| 34 |
this.list.store.add(data); |
| 35 |
this.setDetailsContext(index, e); |
| 36 |
}, |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
init: function(){ |
| 41 |
var list = this.list; |
| 42 |
if(!list.Store){ |
| 43 |
list.setStore(this.loadedStores.listStore); |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
this.list.on("click", lang.hitch(this, function(e){ |
| 56 |
console.log("List on click hit ",e); |
| 57 |
var item = this.list.store.query({"label": e.target.innerHTML}); |
| 58 |
var index = this.list.store.index[item[0].id]; |
| 59 |
console.log("index is "+index); |
| 60 |
this.setDetailsContext(index, e, this.params); |
| 61 |
})); |
| 62 |
|
| 63 |
this.listInsert1.on("click", lang.hitch(this, function(e){ |
| 64 |
console.log("listInsert1 on click hit ",e); |
| 65 |
var index = this.list.store.data.length; |
| 66 |
this.insertResult(index, e); |
| 67 |
})); |
| 68 |
|
| 69 |
}, |
| 70 |
|
| 71 |
|
| 72 |
destroy: function(){ |
| 73 |
|
| 74 |
} |
| 75 |
}; |
| 76 |
}); |