Skip to content

Commit 21cdbaa

Browse files
committed
fixes and improvements on 'destroy' method
cleaning alias field
1 parent 31d86f4 commit 21cdbaa

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

jquery.flexdatalist.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Autocomplete input fields, with support for datalists.
44
*
55
* Version:
6-
* 2.2.0
6+
* 2.2.0.1
77
*
88
* Depends:
99
* jquery.js > 1.8.3
@@ -28,7 +28,7 @@ jQuery.fn.flexdatalist = function (_option, _value) {
2828

2929
if ($aliascontainer) {
3030
$this.removeClass('flexdatalist-set')
31-
.attr('type', 'text')
31+
.attr('style', null)
3232
.val((options && options.originalValue && !clear ? options.originalValue : ''))
3333
.removeData('flexdatalist')
3434
.removeData('aliascontainer');
@@ -353,40 +353,36 @@ jQuery.fn.flexdatalist = function (_option, _value) {
353353
if ($alias.attr('autofocus')) {
354354
$alias.focus();
355355
}
356-
$this.data('aliascontainer', ($multiple ? $multiple : $alias));
357-
this.chained();
358-
$this.css({
356+
$this.data('aliascontainer', ($multiple ? $multiple : $alias)).addClass('flexdatalist flexdatalist-set').css({
359357
'position': 'absolute',
360358
'top': -14000,
361359
'left': -14000
362360
});
363-
$alias.attr('style', null);
361+
this.chained();
364362
},
365363
/**
366364
* Single value input.
367365
*/
368366
alias: function () {
369-
var id = ($this.attr('id') ? $this.attr('id') + '-flexdatalist' : fid);
370-
var $alias = $this
371-
.clone(false)
367+
var aliasid = ($this.attr('id') ? $this.attr('id') + '-flexdatalist' : fid);
368+
var $alias = $('<input type="text">')
372369
.attr({
373-
'list': null,
370+
'class': $this.attr('class'),
374371
'name': ($this.attr('name') ? 'flexdatalist-' + $this.attr('name') : null),
375-
'id': id,
372+
'id': aliasid,
376373
'value': ''
377374
})
378-
.addClass('flexdatalist-alias ' + id)
375+
.addClass('flexdatalist-alias ' + aliasid)
379376
.removeClass('flexdatalist')
380377
.attr('autocomplete', 'off');
381-
$this.addClass('flexdatalist flexdatalist-set')
382378
return $alias;
383379
},
384380
/**
385381
* Multiple values input/list
386382
*/
387383
multipleInput: function ($alias) {
388384
$multiple = $('<ul tabindex="1">')
389-
.addClass('flexdatalist-multiple ' + id)
385+
.addClass('flexdatalist-multiple ' + fid)
390386
.css({
391387
'border-color': $this.css('border-left-color'),
392388
'border-width': $this.css('border-left-width'),

0 commit comments

Comments
 (0)