allow apply selector more than once, fix #312
This commit is contained in:
parent
62da4f7cd3
commit
db5b8fd070
@ -3,6 +3,7 @@ X-editable changelog
|
||||
|
||||
Version 1.4.6 wip
|
||||
----------------------------
|
||||
[bug #312] can't apply selector more than once (vitalets)
|
||||
[enh #48] textarea: use `white-space: pre-wrap` instead of nl2br conversion (vitalets)
|
||||
[enh #286] added HTML5 time input (Doggie52)
|
||||
[enh] add `defaultValue` option (vitalets)
|
||||
|
@ -621,6 +621,14 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
data = $this.data(datakey),
|
||||
options = typeof option === 'object' && option;
|
||||
|
||||
//for delegated targets do not store `editable` object for element
|
||||
//it's allows several different selectors.
|
||||
//see: https://github.com/vitalets/x-editable/issues/312
|
||||
if(options && options.selector) {
|
||||
data = new Editable(this, options);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
$this.data(datakey, (data = new Editable(this, options)));
|
||||
}
|
||||
|
@ -647,13 +647,19 @@
|
||||
|
||||
test("`selector` option", function () {
|
||||
var parent = $('<div><a href="#" id="a" data-type="text">123</a></div>').appendTo('#qunit-fixture').editable({
|
||||
selector: 'a',
|
||||
url: 'post.php',
|
||||
source: groups
|
||||
selector: '#a',
|
||||
url: 'post.php'
|
||||
}),
|
||||
b = $('<a href="#" id="b" data-type="select" data-value="1"></a>'),
|
||||
e = $('#a'),
|
||||
selected = 2;
|
||||
|
||||
//apply delegated editable second time
|
||||
parent.editable({
|
||||
selector: '#b',
|
||||
url: 'post.php',
|
||||
source: groups
|
||||
});
|
||||
|
||||
ok(!e.hasClass('editable'), 'no editable class applied');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user