Permalink
Browse files

escape jquery meta-characters . and @

  • Loading branch information...
1 parent c437445 commit 93a9f10434677dbb6bc69f0c9cb1f1d5afeed6d8 Francisco Treacy committed Apr 2, 2010
Showing with 4 additions and 1 deletion.
  1. +4 −1 index.html
View
@@ -35,7 +35,10 @@
function edit(key) {
var selector = '#' + key + '-object';
+ selector = selector.replace(/([\.@])/g, '\\$1');
+ console.log(selector);
var $target = $(selector);
+ console.log($target);
var $error = $('<div id="error" class="error"></div>');
var $textarea = $("<textarea style='width:90%; height: 300px' />");
@@ -93,7 +96,7 @@
function show(key) {
db.get(bucket, key)(function(response) {
- $('#document').html("<a href='javascript:;' onclick='remove(\"" + key + "\")'>delete</a> | " +
+ $('#document').html("<a href='javascript:;' onclick='edit()'>new</a> | <a href='javascript:;' onclick='remove(\"" + key + "\")'>delete</a> | " +
"<a href='javascript:;' onclick='edit(\"" + key + "\")'>edit</a>");
$('#document').append("<dt>Object<dt><dd><pre id='" + key + "-object'>" + JSON.stringify(response, null, 2) + "</pre></dd>");
});

0 comments on commit 93a9f10

Please sign in to comment.