PDA

View Full Version : Handling of object tuples



zeeg
3 Nov 2006, 2:29 AM
I'm suggesting adding a fallback when someone (like me) mistakenly has a tuple instead of a list.

My previous code:

_y_domh.append('contentshell', {tag: 'form', action: '/' + cu_lang + '/accounts/login/', method: 'post', id: 'js_login_form', children: [
{tag: 'p', children: [
{tag: 'label', html: 'Username:'},
{tag: 'input', type: 'text', cls: 'text', name: 'username', id: 'id_username'},
]},
{tag: 'p', children: [
{tag: 'label', html: 'Password:'},
{tag: 'input', type: 'password', cls: 'text', name: 'password', id: 'id_password'},
]},
{tag: 'div', cls: 'tr', children: [
{tag: 'a', href: '/' + cu_lang + '/accounts/register/', html: 'New Account', cls: 'register'},
{tag: 'input', type: 'submit', cls: 'button', value: 'Login'},
]},
{tag: 'input', type: 'hidden', name: 'cookieuser', value: '1'},
{tag: 'input', type: 'hidden', name: 'next', value: cu_nextpage},
]});
This was causing issues, as it was looking for another object in createHTML, which didn't exist. Someone suggested a if (!o) return '';

jack.slocum
3 Nov 2006, 12:16 PM
You have an extra comma:

{tag: 'input', type: 'hidden', name: 'cookieuser', value: '1'},
{tag: 'input', type: 'hidden', name: 'next', value: cu_nextpage}, <-- extra comma
]});

jack.slocum
3 Nov 2006, 12:16 PM
Actually, they all have an extra comma.