Skip to content

Commit c1fb0b1

Browse files
author
Sandro Tajè
committed
isolate form fix
1 parent c45d63b commit c1fb0b1

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

dist/angular-uikit.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ <h1 class="uk-article-title">Sortable</h1>
4545

4646
<article class="uk-article">
4747
<h1 class="uk-article-title">JSON Table Form</h1>
48-
<uk-ng-json-table-form model="vm.jsonTableModel" structure="vm.structure" can-reorder="true" submit-on-enter="true" read-only="true"></uk-ng-json-table-form>
48+
<form name="form" ng-submit="save(mt.machineType)">
49+
<uk-ng-json-table-form model="vm.jsonTableModel" structure="vm.structure" can-reorder="true" submit-on-enter="true" read-only="false"></uk-ng-json-table-form>
50+
{{form.$valid}}
51+
</form>
52+
4953

50-
{{vm.jsonTableModel | json}}
54+
<!-- {{vm.jsonTableModel | json}} -->
5155
</article>
5256

5357
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-uikit",
3-
"version": "1.3.16",
3+
"version": "1.3.17",
44
"description": "Angular Uikit binding",
55
"main": "./dist/angular-uikit.min.js",
66
"scripts": {

src/angular-uikit.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,27 @@ angular.module('angularUikit', [])
2424
if (!ctrl) {
2525
return;
2626
}
27-
27+
2828
// Do a copy of the controller
2929
var ctrlCopy = {};
3030
angular.copy(ctrl, ctrlCopy);
31-
31+
3232
// Get the parent of the form
3333
var parent = elm.parent().controller('form');
3434
// Remove parent link to the controller
3535
parent.$removeControl(ctrl);
36-
36+
3737
// Replace form controller with a "isolated form"
38-
var isolatedFormCtrl = {
39-
$setValidity: function (validationToken, isValid, control) {
40-
ctrlCopy.$setValidity(validationToken, isValid, control);
41-
parent.$setValidity(validationToken, true, ctrl);
42-
},
43-
$setDirty: function () {
44-
elm.removeClass('ng-pristine').addClass('ng-dirty');
45-
ctrl.$dirty = true;
46-
ctrl.$pristine = false;
47-
},
38+
ctrl.$setValidity = function (validationToken, isValid, control) {
39+
ctrlCopy.$setValidity(validationToken, isValid, control);
40+
parent.$setValidity(validationToken, true, ctrl);
41+
};
42+
ctrl.$setDirty = function () {
43+
elm.removeClass('ng-pristine').addClass('ng-dirty');
44+
ctrl.$dirty = true;
45+
ctrl.$pristine = false;
4846
};
49-
angular.extend(ctrl, isolatedFormCtrl);
5047
}
5148
};
52-
}]);;
49+
}]);
50+
;

0 commit comments

Comments
 (0)