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

Custom event variable, to know if checkbox was checked or unchecked #128

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checklist-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ angular.module('checklist-model', [])
setValueInChecklistModel(getChecklistValue(), newValue);

if (checklistChange) {
checklistChange(scope);
checklistChange(scope, { "$checked": newValue });
}
});

Expand Down
9 changes: 8 additions & 1 deletion docs/blocks/event/ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ app.controller('Ctrl5', function($scope) {
};

$scope.testValue = 'Im not changed yet!';
$scope.imChanged = function(){
$scope.imChanged = function(checked, key) {
if (checked) {
console.log(key + " activated")
}
else {
console.log(key + " deactivated")
}

$scope.testValue = $scope.user.roles.join(',');
}
$scope.shouldChange = function(key){
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks/event/view.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<label ng-repeat="(key, text) in roles">
<input type="checkbox" checklist-before-change="shouldChange(key)" checklist-change="imChanged()" checklist-model="user.roles" checklist-value="key"> {{text}}
<input type="checkbox" checklist-before-change="shouldChange(key)" checklist-change="imChanged($checked, key)" checklist-model="user.roles" checklist-value="key"> {{text}}
</label>
22 changes: 18 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ <h2 style="margin-bottom: 0">Event</h2>
<div class="col-xs-12 col-sm-6">
<h3>demo</h3>
<div class="well"><label ng-repeat="(key, text) in roles">
<input type="checkbox" checklist-before-change="shouldChange(key)" checklist-change="imChanged()" checklist-model="user.roles" checklist-value="key"> {{text}}
<input type="checkbox" checklist-before-change="shouldChange(key)" checklist-change="imChanged($checked, key)" checklist-model="user.roles" checklist-value="key"> {{text}}
</label></div>
<script>app.controller('Ctrl5', function($scope) {
$scope.roles = {
Expand All @@ -920,7 +920,14 @@ <h3>demo</h3>
};

$scope.testValue = 'Im not changed yet!';
$scope.imChanged = function(){
$scope.imChanged = function(checked, key) {
if (checked) {
console.log(key + " activated")
}
else {
console.log(key + " deactivated")
}

$scope.testValue = $scope.user.roles.join(',');
}
$scope.shouldChange = function(key){
Expand Down Expand Up @@ -963,7 +970,7 @@ <h3>testValue</h3>
<div class="col-xs-12">
<h3>html</h3>
<pre class="prettyprint ng-non-bindable">&lt;label ng-repeat=&quot;(key, text) in roles&quot;&gt;
&lt;input type=&quot;checkbox&quot; checklist-before-change=&quot;shouldChange(key)&quot; checklist-change=&quot;imChanged()&quot; checklist-model=&quot;user.roles&quot; checklist-value=&quot;key&quot;&gt; {{text}}
&lt;input type=&quot;checkbox&quot; checklist-before-change=&quot;shouldChange(key)&quot; checklist-change=&quot;imChanged($checked, key)&quot; checklist-model=&quot;user.roles&quot; checklist-value=&quot;key&quot;&gt; {{text}}
&lt;/label&gt;</pre>
<h3>js</h3>
<pre class="prettyprint">var app = angular.module(&quot;app&quot;, [&quot;checklist-model&quot;]);
Expand All @@ -976,7 +983,14 @@ <h3>js</h3>
};

$scope.testValue = 'Im not changed yet!';
$scope.imChanged = function(){
$scope.imChanged = function(checked, key) {
if (checked) {
console.log(key + &quot; activated&quot;)
}
else {
console.log(key + &quot; deactivated&quot;)
}

$scope.testValue = $scope.user.roles.join(',');
}
$scope.shouldChange = function(key){
Expand Down