From afe4f6a79489ba5eafcea74cac27e336932a5dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 16 Sep 2013 13:47:37 +0200 Subject: [PATCH] add exists method to jquery --- core/js/js.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/js/js.js b/core/js/js.js index c09f80369f..cb7287c02a 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -906,7 +906,7 @@ OC.set=function(name, value) { * @param {type} start * @param {type} end */ -$.fn.selectRange = function(start, end) { +jQuery.fn.selectRange = function(start, end) { return this.each(function() { if (this.setSelectionRange) { this.focus(); @@ -921,6 +921,15 @@ $.fn.selectRange = function(start, end) { }); }; +/** + * check if an element exists. + * allows you to write if ($('#myid').exists()) to increase readability + * @link http://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery + */ +jQuery.fn.exists = function(){ + return this.length > 0; +} + /** * Calls the server periodically every 15 mins to ensure that session doesnt * time out