binding? scoping?
Stéphane Boi...
5 posts
|
Bonjour, I was wondering if you could help me out with a little problem. I am doing something based on the dragdrop 5 example.
function CreateSortableGroups(){
var url = 'controller.php?Action=GetGroupsName';
var myAjax = new Ajax.Request(url,
{method: 'get', onComplete: function (arg){
console.log('Foo1');
var GroupNames = arg.responseText.pluck('FieldGroupID');
GroupNames.each(function(n){
console.log('foo2');
var options = {
constraint: false, containment: GroupNames,
dropOnEmpty: true, onUpdate: function(list) {
var methodStart = list.down('li') ? 'remove' : 'add';
list[methodStart + 'ClassName']('FieldGroupEmpty');
}
};
console.log('foo3');
console.log(options);
Sortable.create(n, options);
})
}
}
);
}
Now strangely the Groups (a JSON array of IDs already Created that gets returned) get created as sortables but not with the options and foo2 and foo3 and options are not sent to the console… I<m foolish be very something to bound this i is sure><m of aware not jsut> thanks |
Christophe P...
28 posts
|
Hey Stéphane, could you please (a) repost with proper code formatting, and (b) rephrase what you say after the code? I just can’t understand your last sentence! Thanks :-) |
Stéphane Boi...
5 posts
|
function CreateSortableGroups(){
var url = 'controller.php?Action=GetGroupsName';
var myAjax = new Ajax.Request(url,
{method: 'get', onComplete: function (arg){
console.log('Foo1');
var GroupNames = arg.responseText.pluck('FieldGroupID');
GroupNames.each(function(n){
console.log('foo2');
var options = {
constraint: false, containment: GroupNames,
dropOnEmpty: true, onUpdate: function(list) {
var methodStart = list.down('li') ? 'remove' : 'add';
list[methodStart + 'ClassName']('FieldGroupEmpty');
}
};
console.log('foo3');
console.log(options);
Sortable.create(n, options);
})
}
}
);
}
Clarifications: (En Francais sa va etre plus facile bon) GroupNames deviens un array de ID de element ul dans le log de firebug foo1 apparait mais foo2, foo3 et la variable option n’apparaise pas. Merci pour ton temps, C’est vraiment apprécié. |
Stéphane Boi...
5 posts
|
Answered it myself the offending line is this: For some strange reason I thought since I did a JSON response header that it would be automatically into a JSON array. doing an evail before the pluck solved the problem. |
Christophe P...
28 posts
|
That’s because you used responseText instead of responseJSON, tss tss… |
5 posts, 2 voices
