1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
var currentBagId = 'default';
var currentBagAction = 'default';
// la def de mon invocation AJAX
var lockBag = {
url: 'lockBag.do',
content: { bagId: currentBagId, bagAction:currentBagAction },
form: "mainForm",
handleAs: "json",
load: function(response, ioArgs){
alert('here');
store = new dojo.data.ItemFileWriteStore({data:response});
store.fetch({
onComplete: function(items, result){
dojo.forEach(items, function(item){
var itemId = store.getIdentity(item);
myItem = item;
jsonStore.fetchItemByIdentity({
identity: itemId,
onItem: handleFetchByIdentityForLock
});
});
}
});
return;
},
error: function(response, ioArgs) {
return response; //
},
timeout: 4000
};
// la méthode qui réagit au clic
var selectItem = function(item)
{
if (item && jsonStore.isItem( item ))
{
var val = jsonStore.getValue(item,"selected");
var newVal = ((val==true) ? false : true);
if(newVal==true)
{
currentBagId = jsonStore.getValue(item,"bagId");
alert('currentbagId: ' + currentBagId);
currentBagAction = 'select';
dojo.xhrGet(lockBag);
}
else
{
currentBagId = jsonStore.getValue(item,"bagId");
currentBagAction = 'unselect';
dojo.xhrGet(lockBag);
}
}
} |
Partager