diff --git a/templates/2k11/admin/serendipity_editor.js.tpl b/templates/2k11/admin/serendipity_editor.js.tpl index 0a7a3387..7c1ed52a 100644 --- a/templates/2k11/admin/serendipity_editor.js.tpl +++ b/templates/2k11/admin/serendipity_editor.js.tpl @@ -174,8 +174,7 @@ function choose_media(id) { // "Transfer" value from media db popup to form element, used for example for selecting a category-icon function serendipity_imageSelector_addToElement (str, id) { - id = id.replace(/\[/g, "\\["); // jQuery fails to select the input when the selector contains unescaped [ or ] - id = id.replace(/\]/g, "\\]"); + id = escapeBrackets(str); var $input = $('#'+id); $input.val(str); @@ -187,6 +186,14 @@ function serendipity_imageSelector_addToElement (str, id) { $input.change(); } +// Escape an id with [ in it to be able to be used as selector +// jQuery fails to select the input when the selector contains unescaped [ or ] +function escapeBrackets(str) { + str = str.replace(/\[/g, "\\["); + str = str.replace(/\]/g, "\\]"); + return str; +} + // Add another (image) keyword function AddKeyword(keyword) { s = document.getElementById('keyword_input').value;