- HiFi műszaki szemmel - sztereó hangrendszerek
- VR topik
- Milyen TV-t vegyek?
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Projektor topic
- Otthoni időjárás-állomás
- Gaming notebook topik
- Nem kell még temetni: 2 éves órajelcsúcsot döntöttek meg Raptor Lake-kel
- Nem indul és mi a baja a gépemnek topik
- A Linux megnégyszerezte magát a Steamen — a Microsoft ismét ígérget
-
Fórumok
PROHARDVER! - hardver fórumok
Notebookok TV & Audió Digitális fényképezés Alaplapok, chipsetek, memóriák Processzorok, tuning Hűtés, házak, tápok, modding Videokártyák Monitorok Adattárolás Multimédia, életmód, 3D nyomtatás Nyomtatók, szkennerek Tabletek, E-bookok PC, mini PC, barebone, szerver Beviteli eszközök Egyéb hardverek PROHARDVER! BlogokMobilarena - mobil fórumok
Okostelefonok Mobiltelefonok Okosórák Autó+mobil Üzlet és Szolgáltatások Mobilalkalmazások Tartozékok, egyebek Mobilarena blogokIT café - infotech fórumok
Infotech Hálózat, szolgáltatók OS, alkalmazások SzoftverfejlesztésGAMEPOD - játék fórumok
PC játékok Konzol játékok MobiljátékokLOGOUT - lépj ki, lépj be!
LOGOUT reakciók Monologoszféra FototrendFÁRADT GŐZ - közösségi tér szinte bármiről
Tudomány, oktatás Sport, életmód, utazás, egészség Kultúra, művészet, média Gazdaság, jog Technika, hobbi, otthon Társadalom, közélet Egyéb Lokál PROHARDVER! interaktív
-
Frissítve: 2014-02-25 10:20 Téma összefoglaló
JavaScript != Java (A JavaScript nem összekeverendő a Javával, két különböző programozási nyelvről van szó!)
Új hozzászólás Aktív témák
-
CSorBA
őstag
Hi! Az események buborékszerű felszivárgásáról itt írtam, belinkelve egy példát:
http://prohardver.hu/tema/weblap_keszites/hsz_10515-10516.html
http://prohardver.hu/tema/weblap_keszites/hsz_10543-10543.htmlAz AJAX-os betöltött elemekre kötött event handlerekre jó példa a jQuery.on(), ahol a "delegated events" rész az érdekes, itt tök jól elmagyarázza a helyzetet (kiemeltem a nagyon fontos részeket):
"Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers. This element could be the container element of a view in a Model-View-Controller design, for example, or document if the event handler wants to monitor all bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach events there without waiting for the document to be ready.
In addition to their ability to handle events on descendant elements not yet created, another advantage of delegated events is their potential for much lower overhead when many elements must be monitored. On a data table with 1,000 rows in its tbody, this example attaches a handler to 1,000 elements:
$( "#dataTable tbody tr" ).on( "click", function() {
alert( $( this ).text() );
});A delegated-events approach attaches an event handler to only one element, the tbody, and the event only needs to bubble up one level (from the clicked tr to tbody):
$( "#dataTable tbody" ).on( "click", "tr", function() {
alert( $( this ).text() );
});[...]
Attaching many delegated event handlers near the top of the document tree can degrade performance. Each time the event occurs, jQuery must compare all selectors of all attached events of that type to every element in the path from the event target up to the top of the document. For best performance, attach delegated events at a document location as close as possible to the target elements. Avoid excessive use of document or document.body for delegated events on large documents.
jQuery can process simple selectors of the form tag#id.class very quickly when they are used to filter delegated events. So, "#myForm", "a.external", and "button" are all fast selectors. Delegated events that use more complex selectors, particularly hierarchical ones, can be several times slower--although they are still fast enough for most applications. Hierarchical selectors can often be avoided simply by attaching the handler to a more appropriate point in the document. For example, instead of $( "body" ).on( "click", "#commentForm .addNew", addComment ) use $( "#commentForm" ).on( "click", ".addNew", addComment )."
Itt tehát a példában az eseménykezelőt a tbody-ra kötötte, ahelyett, hogy az összes tr-re tette volna ugyanezt, így az eseménynek csak pontosan egy szintet kell buborékszerűen felúsznia, a klikkelt tr elemből a tbody felé.
Ide felraktam egy egyszerű példát:
http://jsfiddle.net/Sk8erPeter/Tpc3k/
itt például gombokat adok hozzá egy container elemhez. Az első példában csak az első gomb "reagál" (dob alert() ablakot), mert konkrétan a kód lefutásának pillanatában jelenlévő button elemre kötöttem az event handlert; a második esetben viszont amikor hozzáadok újabb gombokat, azok is dobnak alert()-ablakokat, hiszen ott azt határoztam meg, hogy a szülőelemre legyen kötve az event handler (egyébként itt a lényeg a hierarchia, nem az, hogy közvetlen szülőeleme legyen!), és megadtam egy selectort is (ami a "button"), hogy a leszármazott elemek közül ezekre szűrjön az eseménykezelés során, ezek triggereljék a click eseményt.
Lásd a doksiban a leírást a selectorra:
selector
Type: String
A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.Tehát a különbség:
első:
$container1.find('button').on('click', function (event) { ... } );
második:
$container2.on('click', 'button', function (event) { ... } );Remélem, nagyjából érthető, ha valami nem tiszta, mert bonyolultan írtam, kérdezz nyugodtan
Most jött el a kérdés ideje ezzel a hozzászólással kapcsolatban

Azt vettem észre, hogy click eventnél ez teljesen jól működik, viszont scroll esetében valamiért nem fut le, csak direktben pakolva. De az pedig ugye nem lesz jó a később behozott elemek esetén..
Itt a példám: [link] Mi a gond a scrollal?
-
CSorBA
őstag
Hi! Az események buborékszerű felszivárgásáról itt írtam, belinkelve egy példát:
http://prohardver.hu/tema/weblap_keszites/hsz_10515-10516.html
http://prohardver.hu/tema/weblap_keszites/hsz_10543-10543.htmlAz AJAX-os betöltött elemekre kötött event handlerekre jó példa a jQuery.on(), ahol a "delegated events" rész az érdekes, itt tök jól elmagyarázza a helyzetet (kiemeltem a nagyon fontos részeket):
"Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers. This element could be the container element of a view in a Model-View-Controller design, for example, or document if the event handler wants to monitor all bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach events there without waiting for the document to be ready.
In addition to their ability to handle events on descendant elements not yet created, another advantage of delegated events is their potential for much lower overhead when many elements must be monitored. On a data table with 1,000 rows in its tbody, this example attaches a handler to 1,000 elements:
$( "#dataTable tbody tr" ).on( "click", function() {
alert( $( this ).text() );
});A delegated-events approach attaches an event handler to only one element, the tbody, and the event only needs to bubble up one level (from the clicked tr to tbody):
$( "#dataTable tbody" ).on( "click", "tr", function() {
alert( $( this ).text() );
});[...]
Attaching many delegated event handlers near the top of the document tree can degrade performance. Each time the event occurs, jQuery must compare all selectors of all attached events of that type to every element in the path from the event target up to the top of the document. For best performance, attach delegated events at a document location as close as possible to the target elements. Avoid excessive use of document or document.body for delegated events on large documents.
jQuery can process simple selectors of the form tag#id.class very quickly when they are used to filter delegated events. So, "#myForm", "a.external", and "button" are all fast selectors. Delegated events that use more complex selectors, particularly hierarchical ones, can be several times slower--although they are still fast enough for most applications. Hierarchical selectors can often be avoided simply by attaching the handler to a more appropriate point in the document. For example, instead of $( "body" ).on( "click", "#commentForm .addNew", addComment ) use $( "#commentForm" ).on( "click", ".addNew", addComment )."
Itt tehát a példában az eseménykezelőt a tbody-ra kötötte, ahelyett, hogy az összes tr-re tette volna ugyanezt, így az eseménynek csak pontosan egy szintet kell buborékszerűen felúsznia, a klikkelt tr elemből a tbody felé.
Ide felraktam egy egyszerű példát:
http://jsfiddle.net/Sk8erPeter/Tpc3k/
itt például gombokat adok hozzá egy container elemhez. Az első példában csak az első gomb "reagál" (dob alert() ablakot), mert konkrétan a kód lefutásának pillanatában jelenlévő button elemre kötöttem az event handlert; a második esetben viszont amikor hozzáadok újabb gombokat, azok is dobnak alert()-ablakokat, hiszen ott azt határoztam meg, hogy a szülőelemre legyen kötve az event handler (egyébként itt a lényeg a hierarchia, nem az, hogy közvetlen szülőeleme legyen!), és megadtam egy selectort is (ami a "button"), hogy a leszármazott elemek közül ezekre szűrjön az eseménykezelés során, ezek triggereljék a click eseményt.
Lásd a doksiban a leírást a selectorra:
selector
Type: String
A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.Tehát a különbség:
első:
$container1.find('button').on('click', function (event) { ... } );
második:
$container2.on('click', 'button', function (event) { ... } );Remélem, nagyjából érthető, ha valami nem tiszta, mert bonyolultan írtam, kérdezz nyugodtan
Éreztem én, hogy téged kell megszólítani
Szerintem lassan összedobhatnánk a fórumtársakkal egy sörözést és neked pár sört 
Nagyon hasznos leírás, letisztult a kép azt hiszem. Még talán annyi, hogy ugye jQueryben az onclick is valójában .on?
-
trisztan94
őstag
Hi! Az események buborékszerű felszivárgásáról itt írtam, belinkelve egy példát:
http://prohardver.hu/tema/weblap_keszites/hsz_10515-10516.html
http://prohardver.hu/tema/weblap_keszites/hsz_10543-10543.htmlAz AJAX-os betöltött elemekre kötött event handlerekre jó példa a jQuery.on(), ahol a "delegated events" rész az érdekes, itt tök jól elmagyarázza a helyzetet (kiemeltem a nagyon fontos részeket):
"Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers. This element could be the container element of a view in a Model-View-Controller design, for example, or document if the event handler wants to monitor all bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach events there without waiting for the document to be ready.
In addition to their ability to handle events on descendant elements not yet created, another advantage of delegated events is their potential for much lower overhead when many elements must be monitored. On a data table with 1,000 rows in its tbody, this example attaches a handler to 1,000 elements:
$( "#dataTable tbody tr" ).on( "click", function() {
alert( $( this ).text() );
});A delegated-events approach attaches an event handler to only one element, the tbody, and the event only needs to bubble up one level (from the clicked tr to tbody):
$( "#dataTable tbody" ).on( "click", "tr", function() {
alert( $( this ).text() );
});[...]
Attaching many delegated event handlers near the top of the document tree can degrade performance. Each time the event occurs, jQuery must compare all selectors of all attached events of that type to every element in the path from the event target up to the top of the document. For best performance, attach delegated events at a document location as close as possible to the target elements. Avoid excessive use of document or document.body for delegated events on large documents.
jQuery can process simple selectors of the form tag#id.class very quickly when they are used to filter delegated events. So, "#myForm", "a.external", and "button" are all fast selectors. Delegated events that use more complex selectors, particularly hierarchical ones, can be several times slower--although they are still fast enough for most applications. Hierarchical selectors can often be avoided simply by attaching the handler to a more appropriate point in the document. For example, instead of $( "body" ).on( "click", "#commentForm .addNew", addComment ) use $( "#commentForm" ).on( "click", ".addNew", addComment )."
Itt tehát a példában az eseménykezelőt a tbody-ra kötötte, ahelyett, hogy az összes tr-re tette volna ugyanezt, így az eseménynek csak pontosan egy szintet kell buborékszerűen felúsznia, a klikkelt tr elemből a tbody felé.
Ide felraktam egy egyszerű példát:
http://jsfiddle.net/Sk8erPeter/Tpc3k/
itt például gombokat adok hozzá egy container elemhez. Az első példában csak az első gomb "reagál" (dob alert() ablakot), mert konkrétan a kód lefutásának pillanatában jelenlévő button elemre kötöttem az event handlert; a második esetben viszont amikor hozzáadok újabb gombokat, azok is dobnak alert()-ablakokat, hiszen ott azt határoztam meg, hogy a szülőelemre legyen kötve az event handler (egyébként itt a lényeg a hierarchia, nem az, hogy közvetlen szülőeleme legyen!), és megadtam egy selectort is (ami a "button"), hogy a leszármazott elemek közül ezekre szűrjön az eseménykezelés során, ezek triggereljék a click eseményt.
Lásd a doksiban a leírást a selectorra:
selector
Type: String
A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.Tehát a különbség:
első:
$container1.find('button').on('click', function (event) { ... } );
második:
$container2.on('click', 'button', function (event) { ... } );Remélem, nagyjából érthető, ha valami nem tiszta, mert bonyolultan írtam, kérdezz nyugodtan
Hihetetlen, hogy milyen kidolgozott profi válaszokat tudsz adni, kb. mindenkinek aki legalább felig ertelmes kerdest tesz fel, le a kalappal. Tenyleg.

Új hozzászólás Aktív témák
-
Fórumok
PROHARDVER! - hardver fórumok
Notebookok TV & Audió Digitális fényképezés Alaplapok, chipsetek, memóriák Processzorok, tuning Hűtés, házak, tápok, modding Videokártyák Monitorok Adattárolás Multimédia, életmód, 3D nyomtatás Nyomtatók, szkennerek Tabletek, E-bookok PC, mini PC, barebone, szerver Beviteli eszközök Egyéb hardverek PROHARDVER! BlogokMobilarena - mobil fórumok
Okostelefonok Mobiltelefonok Okosórák Autó+mobil Üzlet és Szolgáltatások Mobilalkalmazások Tartozékok, egyebek Mobilarena blogokIT café - infotech fórumok
Infotech Hálózat, szolgáltatók OS, alkalmazások SzoftverfejlesztésGAMEPOD - játék fórumok
PC játékok Konzol játékok MobiljátékokLOGOUT - lépj ki, lépj be!
LOGOUT reakciók Monologoszféra FototrendFÁRADT GŐZ - közösségi tér szinte bármiről
Tudomány, oktatás Sport, életmód, utazás, egészség Kultúra, művészet, média Gazdaság, jog Technika, hobbi, otthon Társadalom, közélet Egyéb Lokál PROHARDVER! interaktív
- Asztalos klub
- Parfüm topik
- Ubuntu Linux
- EA Sports WRC '23
- Telekom mobilszolgáltatások
- Elképesztő rajt a Forza Horizon 6-nál - Steamen már most népszerűbb elődjénél
- Samsung Galaxy A56 - megbízható középszerűség
- One otthoni szolgáltatások (TV, internet, telefon)
- HiFi műszaki szemmel - sztereó hangrendszerek
- Star Citizen
- További aktív témák...
- Akció!!! Sosemhasznált! HP OmniBook 5 i7-1355U 16GB 1TB 16" FHD+ Gar.: 1 év
- AMD FX-6300 CPU + ASUS M5A97 EVO R2.0 + GeForce GTX 1060 3GB
- Új - MacBook Pro M5 Pro Chip 14" 15C / 16C / 24 GB RAM / 1TB SSD / Silver / Black - 27% Áfás
- Dell Precision 5560 i5 11500H 16GB 256GB SSD 1920x1200 Matt IPS
- Új - MacBook Pro M5 Chip 14" 10C / 10C / 16 GB RAM / 512 SSD / Silver / Black - 27% Áfás
- Samsung Galaxy A12 64GB, Kártyafüggetlen, 1 Év Garanciával
- iKing.Hu - Apple MacBook Pro 16 M1 Pro (2021) 16GB/512GB karcmentes 81% akku 450 ciklus
- Apple iPhone 17 Pro 256GB & 512GB & 1TB Bontatlan Független Összes Szín / 27% áfás ár
- Telefon felvásárlás! Samsung Galaxy A15, Samsung Galaxy A25, Samsung Galaxy A35, Samsung Galaxy A55
- Azonnali készpénzes GAMER / üzleti notebook felvásárlás személyesen / csomagküldéssel korrekt áron
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest


Szerintem lassan összedobhatnánk a fórumtársakkal egy sörözést és neked pár sört


