From e0c4a70a8d7921e3586f6043a04cf33d6481a2d2 Mon Sep 17 00:00:00 2001 From: daslicht Date: Sun, 22 Jun 2014 10:59:59 +0200 Subject: [PATCH] Update javascript.md Replaced deprecated jQuery live() with on(), updated link to documentation. --- docs/en/topics/javascript.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/en/topics/javascript.md b/docs/en/topics/javascript.md index 89a09cc5f..160a05448 100644 --- a/docs/en/topics/javascript.md +++ b/docs/en/topics/javascript.md @@ -230,7 +230,7 @@ You can then click on any element in the CMS to see which entwine methods are bo ### Keep things simple Resist the temptation to build "cathedrals" of complex interrelated components. In general, you can get a lot done in -jQuery with a few lines of code. Your jQuery code will normally end up as a series of event handlers applied with `jQuery.live()` or jQuery.entwine, rather than a complex object graph. +jQuery with a few lines of code. Your jQuery code will normally end up as a series of event handlers applied with `jQuery.on()` or jQuery.entwine, rather than a complex object graph. ### Don't claim global properties @@ -265,20 +265,20 @@ Ready](http://docs.jquery.com/How_jQuery_Works#Launching_Code_on_Document_Ready) ### Bind events "live" jQuery supports automatically reapplying event handlers when new DOM elements get inserted, mostly through Ajax calls. -This "live binding" saves you from reapplying this step manually. +This "binding" saves you from reapplying this step manually. -Caution: Only applies to certain events, see the [jQuery.live() documentation](http://docs.jquery.com/Events/live). +Caution: Only applies to certain events, see the [jQuery.on() documentation](http://api.jquery.com/on/). Example: Add a 'loading' classname to all pressed buttons :::js // manual binding, only applies to existing elements - $('input[[type=submit]]').bind('click', function() { + $('input[[type=submit]]').on('click', function() { $(this).addClass('loading'); }); - // live binding, applies to any inserted elements as well - $('input[[type=submit]]').live(function() { + // binding, applies to any inserted elements as well + $('input[[type=submit]]').on(function() { $(this).addClass('loading'); }); @@ -419,7 +419,7 @@ HTML JavaScript: :::js - $('.autocomplete input').live('change', function() { + $('.autocomplete input').on('change', function() { var resultsEl = $(this).siblings('.results'); resultsEl.load( // get form action, using the jQuery.metadata plugin @@ -647,4 +647,4 @@ afraid to experiment with using other approaches. * [css](css) * [Unobtrusive Javascript](http://www.onlinetools.org/articles/unobtrusivejavascript/chapter1.html) -* [Quirksmode: In-depth Javascript Resources](http://www.quirksmode.org/resources.html) \ No newline at end of file +* [Quirksmode: In-depth Javascript Resources](http://www.quirksmode.org/resources.html)