Skip to content

Commit

Permalink
hack fixed of on select event
Browse files Browse the repository at this point in the history
  • Loading branch information
fraserxu committed Apr 6, 2014
1 parent 925fe66 commit 260c8ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
24 changes: 13 additions & 11 deletions example/scripts/app.js
Expand Up @@ -31,17 +31,19 @@ angular.module('textcompleteApp', ['ngTextcomplete'])
}
]);

textcomplete.on({
'textComplete:select': function (e, value) {
alert(value);
},
'textComplete:show': function (e) {
$(this).data('autocompleting', true);
},
'textComplete:hide': function (e) {
$(this).data('autocompleting', false);
}
})
$(textcomplete).on({
'textComplete:select': function (e, value) {
scope.$apply(function() {
scope.message = value
})
},
'textComplete:show': function (e) {
$(this).data('autocompleting', true);
},
'textComplete:hide': function (e) {
$(this).data('autocompleting', false);
}
});
}
}
}])
Expand Down
14 changes: 9 additions & 5 deletions ng-textcomplete.js
Expand Up @@ -271,9 +271,11 @@ angular.module('ngTextcomplete', [])
// this.el.innerHTML = pre + post;
// this.placeCaretAtEnd();
// } else {
this.$el.val(pre + post)
.trigger('change')
.trigger('textComplete:select', value);

this.$el.val(pre + post);
$(this).trigger('change')
.trigger('textComplete:select', this.$el.val());

this.el.focus();
this.el.selectionStart = this.el.selectionEnd = pre.length;
// }
Expand Down Expand Up @@ -465,7 +467,8 @@ function(utils) {
activate: function() {
if (!this.shown) {
this.$el.show();
this.completer.$el.trigger('textComplete:show');
$(this).trigger('textComplete:show');
// this.completer.$el.trigger('textComplete:show');
this.shown = true;
}
return this;
Expand All @@ -474,7 +477,8 @@ function(utils) {
deactivate: function() {
if (this.shown) {
this.$el.hide();
this.completer.$el.trigger('textComplete:hide');
$(this).trigger('textComplete:show');
// this.completer.$el.trigger('textComplete:hide');
this.shown = false;
this.data = [];
this.index = null;
Expand Down

0 comments on commit 260c8ea

Please sign in to comment.