allow apply selector more than once, fix #312
This commit is contained in:
		@@ -3,6 +3,7 @@ X-editable changelog
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Version 1.4.6 wip
 | 
					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 #48] textarea: use `white-space: pre-wrap` instead of nl2br conversion (vitalets)
 | 
				
			||||||
[enh #286] added HTML5 time input (Doggie52)
 | 
					[enh #286] added HTML5 time input (Doggie52)
 | 
				
			||||||
[enh] add `defaultValue` option (vitalets)
 | 
					[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), 
 | 
					                data = $this.data(datakey), 
 | 
				
			||||||
                options = typeof option === 'object' && option;
 | 
					                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) {
 | 
					            if (!data) {
 | 
				
			||||||
                $this.data(datakey, (data = new Editable(this, options)));
 | 
					                $this.data(datakey, (data = new Editable(this, options)));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -647,13 +647,19 @@
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
     test("`selector` option", function () {
 | 
					     test("`selector` option", function () {
 | 
				
			||||||
        var parent = $('<div><a href="#" id="a" data-type="text">123</a></div>').appendTo('#qunit-fixture').editable({
 | 
					        var parent = $('<div><a href="#" id="a" data-type="text">123</a></div>').appendTo('#qunit-fixture').editable({
 | 
				
			||||||
            selector: 'a',
 | 
					            selector: '#a',
 | 
				
			||||||
            url: 'post.php',
 | 
					            url: 'post.php'
 | 
				
			||||||
            source: groups
 | 
					 | 
				
			||||||
        }),
 | 
					        }),
 | 
				
			||||||
        b = $('<a href="#" id="b" data-type="select" data-value="1"></a>'),
 | 
					        b = $('<a href="#" id="b" data-type="select" data-value="1"></a>'),
 | 
				
			||||||
        e = $('#a'),
 | 
					        e = $('#a'),
 | 
				
			||||||
        selected = 2;
 | 
					        selected = 2;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //apply delegated editable second time
 | 
				
			||||||
 | 
					        parent.editable({
 | 
				
			||||||
 | 
					           selector: '#b', 
 | 
				
			||||||
 | 
					           url: 'post.php',
 | 
				
			||||||
 | 
					           source: groups
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
       
 | 
					       
 | 
				
			||||||
        ok(!e.hasClass('editable'), 'no editable class applied');
 | 
					        ok(!e.hasClass('editable'), 'no editable class applied');
 | 
				
			||||||
       
 | 
					       
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user