Thread View: pl.comp.lang.javascript
3 messages
3 total messages
Started by aaaa
Wed, 16 Feb 2011 19:23
Wlasny plugin jQuery i this
Author: aaaa
Date: Wed, 16 Feb 2011 19:23
Date: Wed, 16 Feb 2011 19:23
41 lines
1626 bytes
1626 bytes
Hej
Tworze wlasny plugin do jQuery:
$('.piesek').mojPlugin(
{
onChange: function(a,b,c)
{
$(this).val(a+b+c);
}
});
W pluginie mam:
if (settings.onChange != null)
{
settings.onChange(a, b, c);
}
oraz
var settings =
{
'onChange' : null
};
oraz
init : function (options)
{
// If options exist, lets merge them with our default settings
if ( options )
{
$.extend( settings, options );
}
I teraz (this) z $(this).val(a+b+c); odnosi sie do mojego pluginu, a nie do
pola (.piesek).
Mozna jakims trikiem zrobic, zeby odnosilo sie do .piesek?
--
A
Re: Wlasny plugin jQuery i this
Author: Gadjo Delhi
Date: Sat, 19 Feb 2011 10:28
Date: Sat, 19 Feb 2011 10:28
16 lines
1591 bytes
1591 bytes
On 16 Lut, 20:23, "aaaa" <a...@aaaaaaaaaaaaaaaaaaa.com> wrote:
> if (settings.onChange != null)
> {
> settings.onChange(a, b, c);
> }
>
> I teraz (this) z $(this).val(a+b+c); odnosi sie do mojego pluginu, a nie do
> pola (.piesek).
> Mozna jakims trikiem zrobic, zeby odnosilo sie do .piesek?
coś w tym stylu może zadziała albo przynajmniej naprowadzi na właściwy
trop:
$(this).each(function () {
settings.onChange.call(this, a, b, c);
});
Re: Wlasny plugin jQuery i this
Author: aaaa
Date: Mon, 21 Feb 2011 22:10
Date: Mon, 21 Feb 2011 22:10
12 lines
1373 bytes
1373 bytes
Użytkownik "Gadjo Delhi" <jkarczm@gmail.com> napisał
>coś w tym stylu może zadziała albo przynajmniej naprowadzi na właściwy
>trop:
>$(this).each(function () {
> settings.onChange.call(this, a, b, c);
>});
Ano wlasnie- podalem te "this" jako parametr i w sumie styknie. Dzieki!
--
A
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads