Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > pl.comp.lang.javascript > #3197
| X-Received | by 10.66.139.70 with SMTP id qw6mr16546892pab.47.1448120572784; Sat, 21 Nov 2015 07:42:52 -0800 (PST) |
|---|---|
| X-Received | by 10.140.81.49 with SMTP id e46mr364384qgd.10.1448120572540; Sat, 21 Nov 2015 07:42:52 -0800 (PST) |
| Path | csiph.com!xmission!news.glorb.com!mv3no236192igc.0!news-out.google.com!f23ni219qge.0!nntp.google.com!f78no1209018qge.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | pl.comp.lang.javascript |
| Date | Sat, 21 Nov 2015 07:42:52 -0800 (PST) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=89.72.94.100; posting-account=Y8V58QoAAACtLuF8lEt8MaiUjYUTCWP6 |
| NNTP-Posting-Host | 89.72.94.100 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <d8bb1c55-aa00-4bbb-bb65-862e4f875852@googlegroups.com> (permalink) |
| Subject | newbie: problem z keyup() z jQuery |
| From | jivanmukta@poczta.onet.pl |
| Injection-Date | Sat, 21 Nov 2015 15:42:52 +0000 |
| Content-Type | text/plain; charset=ISO-8859-2 |
| Content-Transfer-Encoding | quoted-printable |
| Xref | csiph.com pl.comp.lang.javascript:3197 |
Show key headers only | View raw
Uczę się JavaScriptu. Na razie jestem kiepski. Mam na formularzu (nazwanym formName) pole textarea (nazwane 'Opis:') i chciałbym żeby użytkownik miał informację ile znaków może jeszcze wprowadzić. Robię to tak (używam jQuery na stronie bo jest mi potrzebne do innych rzeczy):
$('form#' + formName + ' textarea#message').keyup(function () { return onKeyUpAtTextArea('contact', 'message'); });
...
function maxLengthOfArea(textarea, counter) {
if (textarea.getAttribute('maxlength') >= textarea.value.length) {
counter.innerHTML = textarea.getAttribute('maxlength') - textarea.value.length;
return true;
}
return false;
}
...
function onKeyUpAtTextArea(controller, elemId) {
'use strict';
var formName = getCurrentFormName(controller);
var currentForm = getCurrentForm(controller);
var textarea = getFormElement(currentForm, elemId);
var counter = $('form#' + formName + ' span#' + elemId + '_left')[0];
return maxLengthOfArea(textarea, counter);
}
Problem w tym, że funkcja onKeyUpAtTextArea nie jest wołana przy naciskaniu klawisza w polu textarea. Debuggując JavaScript zauważyłem, że przy wykonywaniu kodu jQuery:
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
mam:
fn == /\r?\n/g
data == "ReferenceError: data is not defined"
name == ""
jQuery.fn.name == undefined
Czy to może być przyczyną tego że onKeyUpAtTextArea nie jest wywoływana?
Rozwiązanie mi działało, ale po przerobieniu strony na responsywną przestało działać.
Jak rozwiązać problem?
Back to pl.comp.lang.javascript | Previous | Next — Next in thread | Find similar
newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-21 07:42 -0800
Re: newbie: problem z keyup() z jQuery zpksoft <zpksoft@op.pl> - 2015-11-22 05:03 -0800
Re: newbie: problem z keyup() z jQuery nkab@toya.net.pl - 2015-11-22 23:57 -0800
Re: newbie: problem z keyup() z jQuery Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-11-23 11:22 +0100
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-23 06:18 -0800
Re: newbie: problem z keyup() z jQuery Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-11-23 18:11 +0100
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-23 11:03 -0800
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-23 12:11 -0800
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-23 21:44 -0800
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-24 02:45 -0800
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-24 07:29 -0800
Re: newbie: problem z keyup() z jQuery Borys Pogoreło <borys@pl.edu.leszno> - 2015-11-26 00:10 +0100
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-26 00:07 -0800
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-11-26 02:41 -0800
Re: newbie: problem z keyup() z jQuery Borys Pogoreło <borys@pl.edu.leszno> - 2015-11-28 00:07 +0100
Re: newbie: problem z keyup() z jQuery Jivanmukta <jivanmukta@poczta.onet.pl> - 2015-11-28 16:59 +0100
Re: newbie: problem z keyup() z jQuery Borys Pogoreło <borys@pl.edu.leszno> - 2015-11-29 17:30 +0100
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-12-02 06:41 -0800
Re: newbie: problem z keyup() z jQuery zpksoft <zpksoft@op.pl> - 2015-12-03 05:05 -0800
Re: newbie: problem z keyup() z jQuery jivanmukta@poczta.onet.pl - 2015-12-03 09:12 -0800
Re: newbie: problem z keyup() z jQuery Borys Pogoreło <borys@pl.edu.leszno> - 2015-12-06 22:45 +0100
Re: newbie: problem z keyup() z jQuery Jivanmukta <jivanmukta@poczta.onet.pl> - 2015-12-12 13:10 +0100
Re: newbie: problem z keyup() z jQuery Kviat <kviat@NIE_DLA_SPAMUneostrada.pl> - 2015-11-25 17:10 +0100
Re: newbie: problem z keyup() z jQuery Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-11-25 21:10 +0100
csiph-web