Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/05/2011, 08:40
Avatar de Aijoona
Aijoona
Colaborador
 
Fecha de Ingreso: mayo-2011
Ubicación: Buenos Aires
Mensajes: 779
Antigüedad: 13 años
Puntos: 343
Respuesta: this.value o this me devuelve "undefined" en IE

Consejo de amigo, trata de evitar concatenar strings a mansalva, es super desprolijo y te induce a equivocarte.

Alternativas? Instancia los elementos y definile sus atributos o usa algun tipo de plantilla.

Para el segundo caso yo uso la siguiente utilidad:

Código Javascript:
Ver original
  1. /**
  2.  * Reemplaza los placeholders por sus respectivos valores
  3.  *
  4.  *  tpl('Hello {foo}!', { foo: 'world' }); // "Hello world!"
  5.  *
  6.  * @author Aijoona
  7.  * @param {String} str
  8.  * @param {Object} o
  9.  * @param {Boolean} clear
  10.  */
  11. function tpl(str, o, clear) {
  12.     for (var prop in o) {
  13.         if (Object.prototype.hasOwnProperty.call(o, prop)) {
  14.             str = str.replace((new RegExp('\\{' + prop.toString() + '\\}', 'g')), o[prop] || '');
  15.         }
  16.     }
  17.  
  18.     if(clear) {
  19.         str.replace(/\{.+\}/, '');
  20.     }
  21.    
  22.     return str;
  23. }

Que en tu caso se usaria:

Código Javascript:
Ver original
  1. var INPUT_TEMPLATE = '<input class="left" type="text" value="{text}" ' +
  2.     'onBlur="saveNewValueag(\'{id}\', \'{field}\', {value});" />';
  3.  
  4. var input = tpl(INPUT_TEMPLATE, {
  5.     text: 'LINK',
  6.     id: 666,
  7.     field: '_field',
  8.     value: '3010'
  9. });
  10.  
  11. input; // "<input class="left" type="text" value="LINK" onBlur="saveNewValueag('666', '_field', 3010);" />"
__________________
blog | @aijoona