Problema Prototype

Discutii legate de AJAX, jQuery, MooTools, Prototype, Dojo, Yahoo! UI Library,script.aculo.us, ExtJS,AngularJS, Backbone.js, Ember.js, KnockoutJS

Moderator: Moderatori

Avatar utilizator
kyron
Senior Member
Mesaje: 639
Membru din: Joi Sep 16, 2004 1:12 pm
Localitate: Bucuresti
Contact:

Problema Prototype

Mesajde kyron » Mar Noi 07, 2006 4:01 pm

Salut !

Am urmatoarea secventa :

Cod: Selectaţi tot

Event.observe(obiect, 'blur', function(){salveazaPret(obj)}, false);

Event.observe(obiect, 'keypress', function(event){ if(Event.keyCode(event) == Event.KEY_RETURN) salveazaPret(obj)}, false);


De precizat ca "obiect" este un input text.
Primul eveniment, 'blur' merge perfect, in schimb nu reusesc sa fac sa mearga si la apasarea unei taste, enter de exemplu.



Avatar utilizator
ExcalIbvr
Senior Member
Mesaje: 1105
Membru din: Dum Mai 02, 2004 10:56 pm
Localitate: Oradea
Contact:

Mesajde ExcalIbvr » Mar Noi 07, 2006 7:04 pm

Faci tu integrarea, daca te ajuta. E un mic keypress handler:

Cod: Selectaţi tot

function handleKey(e)
{
  // get the event
  e = (!e) ? window.event : e;
  // get the code of the character that has been pressed       
  code = (e.charCode) ? e.charCode :
         ((e.keyCode) ? e.keyCode :
         ((e.which) ? e.which : 0));
  // handle the keydown event       
  if (e.type == "keydown")
  {
    // if enter (code 13) is pressed
    if(code == 13)
    {
      // do stuff on ENTER
    }
  }
}


Înapoi la “Librarii Javascript”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 17 vizitatori