Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #211:ui-select support #300

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions dist/js/xeditable.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,51 @@ angular.module('xeditable').directive('editableSelect', ['editableDirectiveFacto
}
});
}]);

//ui-select
angular.module('xeditable')
.directive('editableUiSelect', function (editableDirectiveFactory) {
var rename = function (tag, el) {
var newEl = angular.element('<' + tag + '/>');
newEl.html(el.html());
var attrs = el[0].attributes;
for (var i = 0; i < attrs.length; ++i) {
newEl.attr(attrs.item(i).nodeName, attrs.item(i).value);
}
return newEl;
};

var match = null;
var choices = null;
var dir = editableDirectiveFactory({
directiveName: 'editableUiSelect',
inputTpl: '<ui-select></ui-select>',
render: function () {
this.parent.render.call(this);
this.inputEl.append(rename('ui-select-match', match));
this.inputEl.append(rename('ui-select-choices', choices));

}
});
var linkOrg = dir.link;

dir.link = function (scope, el, attrs, ctrl) {

var matchEl = el.find('editable-ui-select-match');
var choicesEl = el.find('editable-ui-select-choices');

match = matchEl.clone();
choices = choicesEl.clone();

matchEl.remove();
choicesEl.remove();

return linkOrg(scope, el, attrs, ctrl);
};

return dir;
});

//textarea
angular.module('xeditable').directive('editableTextarea', ['editableDirectiveFactory',
function(editableDirectiveFactory) {
Expand Down