Closed (fixed)
Project:
Simple Dialog
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
3 Jul 2011 at 12:57 UTC
Updated:
17 Jul 2011 at 19:21 UTC
Hi
I've found that dialog attributes that require a boolean false or true value are passed as strings from rel tag. This means that the actual value of the attributes isn't able to take effect.
To fix it, I added the following lines to simple_dialog.js. Does this sound like a decent solution?
Cheers
Luke
// ** Convert text boolean representation to boolean **
if(option[1]==='true') option[1]=true;
else if(option[1]==='false') option[1]=false;
eg.
if (options[i]) {
option = options[i].split(':');
// ** Convert text boolean representation to boolean **
if(option[1]==='true') option[1]=true;
else if(option[1]==='false') option[1]=false;
// If it's a position option, we may need to parse an array
if (option[0] == 'position' && option[1].match(/\[.*,.*\]/)) {
option[1] = option[1].match(/\[(.*)\]/)[1].split(',');
// Check if positions need be converted to int
if (!isNaN(parseInt(option[1][0]))) {
option[1][0] = parseInt(option[1][0]);
}
if (!isNaN(parseInt(option[1][1]))) {
option[1][1] = parseInt(option[1][1]);
}
}
try {
$('#simple-dialog-container').dialog('option', option[0], option[1]);
} catch (err) {
log('[error] Simple Dialog: Could not set dialog option: ' + option[0] + ' with value: ' + option[1] + '. Error: ' + err);
}
}
http://stackoverflow.com/questions/263965/how-can-i-convert-a-string-to-...
Comments
Comment #1
lukusActually, that doesn't work. The check needed to occur after the options are parsed for position values, because the newly created boolean values is (not)isNaN.
Comment #2
drclaw commentedNice catch. I'll roll this into the next commit!
Comment #3
drclaw commentedThis has been committed. Thanks!