Skip to content

Commit 48656f1

Browse files
authored
Allow name attribute on checklist (#770)
1 parent b9eceb4 commit 48656f1

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

docs/demos/dev-checklist/view.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div ng-controller="DevChecklistCtrl">
2-
<a href="#" class="nobuttons" editable-checklist="user.devstatus" e-ng-options="s.value as s.text for s in statuses" buttons="no" blur="submit">
2+
<a href="#" class="nobuttons" editable-checklist="user.devstatus" e-ng-options="s.value as s.text for s in statuses" buttons="no" blur="submit" data-e-name="check_list[]">
33
{{ showStatus() }}
44
</a>&nbsp;&nbsp;
5-
5+
66
<a href="#" class="onchange" editable-checklist="user.devobjectstatus" e-ng-options="s as s.text for s in statuses" buttons="no" blur="submit" e-ng-change="doSomething($data)" e-checklist-comparator="compareFn">
77
{{ showObjectStatus() }}
88
</a>
9-
</div>
9+
</div>

src/js/directives/checklist.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ angular.module('xeditable').directive('editableChecklist', [
99
useCopy: true,
1010
render: function() {
1111
this.parent.render.call(this);
12-
var parsed = editableNgOptionsParser(this.attrs.eNgOptions);
13-
var ngChangeHtml = '';
14-
var ngChecklistComparatorHtml = '';
15-
var ngDisabled = '';
12+
var parsed = editableNgOptionsParser(this.attrs.eNgOptions),
13+
ngChangeHtml = '',
14+
ngChecklistComparatorHtml = '',
15+
ngDisabled = '',
16+
ngNameHtml = '';
1617

1718
if (this.attrs.eNgChange) {
1819
ngChangeHtml = ' ng-change="' + this.attrs.eNgChange + '"';
@@ -22,19 +23,24 @@ angular.module('xeditable').directive('editableChecklist', [
2223
ngChecklistComparatorHtml = ' checklist-comparator="' + this.attrs.eChecklistComparator + '"';
2324
}
2425

25-
if(this.attrs.eNgDisabled){
26+
if (this.attrs.eNgDisabled) {
2627
ngDisabled = ' ng-disabled="' + this.attrs.eNgDisabled+'"';
2728
}
28-
29+
30+
if (this.attrs.eName) {
31+
ngNameHtml = ' name="' + this.attrs.eName + '"';
32+
}
33+
2934
var html = '<label ng-repeat="'+parsed.ngRepeat+'">'+
3035
'<input type="checkbox" checklist-model="$parent.$parent.$data" checklist-value="'+parsed.locals.valueFn+'"' +
31-
ngChangeHtml + ngChecklistComparatorHtml + ngDisabled+'>'+
36+
ngChangeHtml + ngChecklistComparatorHtml + ngNameHtml + ngDisabled + '>'+
3237
'<span ng-bind="'+parsed.locals.displayFn+'"></span></label>';
3338

3439
this.inputEl.removeAttr('ng-model');
3540
this.inputEl.removeAttr('ng-options');
3641
this.inputEl.removeAttr('ng-change');
3742
this.inputEl.removeAttr('checklist-comparator');
43+
this.inputEl.removeAttr('name');
3844
this.inputEl.html(html);
3945
}
4046
});

0 commit comments

Comments
 (0)