How do I disable Buttons on a specific row in a table Angular JS
I am trying to display users in a table along with edit and delete buttons on each row. Below I have added a sample array.
So when a role- "Super-Admin" logins, I need to disable his row's delete button. So that he won't delete himself right. Whereas the next rows' buttons should not be disabled. I'm kinda new to angular JS. Looking for guidance. Thanks in advance.
if (localStorage.getItem("users") === null) {
$scope.users = [{
email: "Vai@yahoo.com",
password: "Sha123",
firstName: "Vai",
lastName: "LSha",
contact: "123-223-8989",
role: "Super-Admin",
company: ""
},
{
email: "Rick@yahoo.com",
password: "Rick123",
firstName: "Rick",
lastName: "Fraiser",
contact: "987-283-2489",
role: "Supplier-User",
company: "Oneplus"
}
];
localStorage.setItem("users", JSON.stringify($scope.users));
} else {
$scope.users = JSON.parse(localStorage.getItem("users"));
}
<tbody>
<tr ng-if="showUser(user)" ng-repeat="user in users | filter: searchUsers track by $index">
<td>{{user.email}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.contact}}</td>
<td>{{user.role}}</td>
<td>{{user.company}}</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit" ng-click="selectUser(user)">Edit</button>
</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete" ng-click="selectUser(user)">Delete</button>
</td>
</tr>
</tbody>
html angularjs
add a comment |
I am trying to display users in a table along with edit and delete buttons on each row. Below I have added a sample array.
So when a role- "Super-Admin" logins, I need to disable his row's delete button. So that he won't delete himself right. Whereas the next rows' buttons should not be disabled. I'm kinda new to angular JS. Looking for guidance. Thanks in advance.
if (localStorage.getItem("users") === null) {
$scope.users = [{
email: "Vai@yahoo.com",
password: "Sha123",
firstName: "Vai",
lastName: "LSha",
contact: "123-223-8989",
role: "Super-Admin",
company: ""
},
{
email: "Rick@yahoo.com",
password: "Rick123",
firstName: "Rick",
lastName: "Fraiser",
contact: "987-283-2489",
role: "Supplier-User",
company: "Oneplus"
}
];
localStorage.setItem("users", JSON.stringify($scope.users));
} else {
$scope.users = JSON.parse(localStorage.getItem("users"));
}
<tbody>
<tr ng-if="showUser(user)" ng-repeat="user in users | filter: searchUsers track by $index">
<td>{{user.email}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.contact}}</td>
<td>{{user.role}}</td>
<td>{{user.company}}</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit" ng-click="selectUser(user)">Edit</button>
</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete" ng-click="selectUser(user)">Delete</button>
</td>
</tr>
</tbody>
html angularjs
don't use a function to do this; the function will be called every time the DOM is updated, and cause slowdowns. Add a property to the user to check against instead.
– Claies
Nov 19 '18 at 19:37
Can you please explain how to do this?
– Vaibhav27
Nov 19 '18 at 19:38
add a comment |
I am trying to display users in a table along with edit and delete buttons on each row. Below I have added a sample array.
So when a role- "Super-Admin" logins, I need to disable his row's delete button. So that he won't delete himself right. Whereas the next rows' buttons should not be disabled. I'm kinda new to angular JS. Looking for guidance. Thanks in advance.
if (localStorage.getItem("users") === null) {
$scope.users = [{
email: "Vai@yahoo.com",
password: "Sha123",
firstName: "Vai",
lastName: "LSha",
contact: "123-223-8989",
role: "Super-Admin",
company: ""
},
{
email: "Rick@yahoo.com",
password: "Rick123",
firstName: "Rick",
lastName: "Fraiser",
contact: "987-283-2489",
role: "Supplier-User",
company: "Oneplus"
}
];
localStorage.setItem("users", JSON.stringify($scope.users));
} else {
$scope.users = JSON.parse(localStorage.getItem("users"));
}
<tbody>
<tr ng-if="showUser(user)" ng-repeat="user in users | filter: searchUsers track by $index">
<td>{{user.email}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.contact}}</td>
<td>{{user.role}}</td>
<td>{{user.company}}</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit" ng-click="selectUser(user)">Edit</button>
</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete" ng-click="selectUser(user)">Delete</button>
</td>
</tr>
</tbody>
html angularjs
I am trying to display users in a table along with edit and delete buttons on each row. Below I have added a sample array.
So when a role- "Super-Admin" logins, I need to disable his row's delete button. So that he won't delete himself right. Whereas the next rows' buttons should not be disabled. I'm kinda new to angular JS. Looking for guidance. Thanks in advance.
if (localStorage.getItem("users") === null) {
$scope.users = [{
email: "Vai@yahoo.com",
password: "Sha123",
firstName: "Vai",
lastName: "LSha",
contact: "123-223-8989",
role: "Super-Admin",
company: ""
},
{
email: "Rick@yahoo.com",
password: "Rick123",
firstName: "Rick",
lastName: "Fraiser",
contact: "987-283-2489",
role: "Supplier-User",
company: "Oneplus"
}
];
localStorage.setItem("users", JSON.stringify($scope.users));
} else {
$scope.users = JSON.parse(localStorage.getItem("users"));
}
<tbody>
<tr ng-if="showUser(user)" ng-repeat="user in users | filter: searchUsers track by $index">
<td>{{user.email}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.contact}}</td>
<td>{{user.role}}</td>
<td>{{user.company}}</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit" ng-click="selectUser(user)">Edit</button>
</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete" ng-click="selectUser(user)">Delete</button>
</td>
</tr>
</tbody>
if (localStorage.getItem("users") === null) {
$scope.users = [{
email: "Vai@yahoo.com",
password: "Sha123",
firstName: "Vai",
lastName: "LSha",
contact: "123-223-8989",
role: "Super-Admin",
company: ""
},
{
email: "Rick@yahoo.com",
password: "Rick123",
firstName: "Rick",
lastName: "Fraiser",
contact: "987-283-2489",
role: "Supplier-User",
company: "Oneplus"
}
];
localStorage.setItem("users", JSON.stringify($scope.users));
} else {
$scope.users = JSON.parse(localStorage.getItem("users"));
}
<tbody>
<tr ng-if="showUser(user)" ng-repeat="user in users | filter: searchUsers track by $index">
<td>{{user.email}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.contact}}</td>
<td>{{user.role}}</td>
<td>{{user.company}}</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit" ng-click="selectUser(user)">Edit</button>
</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete" ng-click="selectUser(user)">Delete</button>
</td>
</tr>
</tbody>
if (localStorage.getItem("users") === null) {
$scope.users = [{
email: "Vai@yahoo.com",
password: "Sha123",
firstName: "Vai",
lastName: "LSha",
contact: "123-223-8989",
role: "Super-Admin",
company: ""
},
{
email: "Rick@yahoo.com",
password: "Rick123",
firstName: "Rick",
lastName: "Fraiser",
contact: "987-283-2489",
role: "Supplier-User",
company: "Oneplus"
}
];
localStorage.setItem("users", JSON.stringify($scope.users));
} else {
$scope.users = JSON.parse(localStorage.getItem("users"));
}
<tbody>
<tr ng-if="showUser(user)" ng-repeat="user in users | filter: searchUsers track by $index">
<td>{{user.email}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td>{{user.contact}}</td>
<td>{{user.role}}</td>
<td>{{user.company}}</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit" ng-click="selectUser(user)">Edit</button>
</td>
<td>
<button ng-disabled="checkRole()" type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete" ng-click="selectUser(user)">Delete</button>
</td>
</tr>
</tbody>
html angularjs
html angularjs
edited Nov 19 '18 at 19:43
Vaibhav27
asked Nov 19 '18 at 19:28
Vaibhav27Vaibhav27
54
54
don't use a function to do this; the function will be called every time the DOM is updated, and cause slowdowns. Add a property to the user to check against instead.
– Claies
Nov 19 '18 at 19:37
Can you please explain how to do this?
– Vaibhav27
Nov 19 '18 at 19:38
add a comment |
don't use a function to do this; the function will be called every time the DOM is updated, and cause slowdowns. Add a property to the user to check against instead.
– Claies
Nov 19 '18 at 19:37
Can you please explain how to do this?
– Vaibhav27
Nov 19 '18 at 19:38
don't use a function to do this; the function will be called every time the DOM is updated, and cause slowdowns. Add a property to the user to check against instead.
– Claies
Nov 19 '18 at 19:37
don't use a function to do this; the function will be called every time the DOM is updated, and cause slowdowns. Add a property to the user to check against instead.
– Claies
Nov 19 '18 at 19:37
Can you please explain how to do this?
– Vaibhav27
Nov 19 '18 at 19:38
Can you please explain how to do this?
– Vaibhav27
Nov 19 '18 at 19:38
add a comment |
1 Answer
1
active
oldest
votes
Try to disable the button if user.role='Super-Admin':
<button [attr.disabled]="user.role=='Super-Admin'? '' : null" ng-disabled="checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
Don't know if it works with this specific example, I'll test it.
UPDATE
I've tested it on angularjs 1.7.5 and a solution could be adding (in your case) multiple expression in ng-disable directive like so:
<button ng-disabled="user.role=='Super-Admin' || checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
or
<button ng-disabled="user.role=='Super-Admin' && checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
depends on what checkRole() function returns.
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381369%2fhow-do-i-disable-buttons-on-a-specific-row-in-a-table-angular-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try to disable the button if user.role='Super-Admin':
<button [attr.disabled]="user.role=='Super-Admin'? '' : null" ng-disabled="checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
Don't know if it works with this specific example, I'll test it.
UPDATE
I've tested it on angularjs 1.7.5 and a solution could be adding (in your case) multiple expression in ng-disable directive like so:
<button ng-disabled="user.role=='Super-Admin' || checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
or
<button ng-disabled="user.role=='Super-Admin' && checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
depends on what checkRole() function returns.
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
add a comment |
Try to disable the button if user.role='Super-Admin':
<button [attr.disabled]="user.role=='Super-Admin'? '' : null" ng-disabled="checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
Don't know if it works with this specific example, I'll test it.
UPDATE
I've tested it on angularjs 1.7.5 and a solution could be adding (in your case) multiple expression in ng-disable directive like so:
<button ng-disabled="user.role=='Super-Admin' || checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
or
<button ng-disabled="user.role=='Super-Admin' && checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
depends on what checkRole() function returns.
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
add a comment |
Try to disable the button if user.role='Super-Admin':
<button [attr.disabled]="user.role=='Super-Admin'? '' : null" ng-disabled="checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
Don't know if it works with this specific example, I'll test it.
UPDATE
I've tested it on angularjs 1.7.5 and a solution could be adding (in your case) multiple expression in ng-disable directive like so:
<button ng-disabled="user.role=='Super-Admin' || checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
or
<button ng-disabled="user.role=='Super-Admin' && checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
depends on what checkRole() function returns.
Try to disable the button if user.role='Super-Admin':
<button [attr.disabled]="user.role=='Super-Admin'? '' : null" ng-disabled="checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
Don't know if it works with this specific example, I'll test it.
UPDATE
I've tested it on angularjs 1.7.5 and a solution could be adding (in your case) multiple expression in ng-disable directive like so:
<button ng-disabled="user.role=='Super-Admin' || checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
or
<button ng-disabled="user.role=='Super-Admin' && checkRole()"
type="button" class="btn btn-danger" data-toggle="modal" data-
target="#myModalDelete"
ng-click="selectUser(user)">Delete</button>
depends on what checkRole() function returns.
edited Nov 19 '18 at 20:32
answered Nov 19 '18 at 19:45


KurohigeKurohige
5841419
5841419
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
add a comment |
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
Thank you! It works perfectly. How do I add another OR condition like: ng-disabled="user.role=='Super-Admin' || 'Supplier-Admin' || checkRole()" ?
– Vaibhav27
Nov 19 '18 at 21:01
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
yes you can have a try! :)
– Kurohige
Nov 19 '18 at 21:12
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
Well. I tried that. Its not working. It just disables all the delete buttons on every row. I even tried like this: ng-disabled="user.role==('Super-Admin' || 'Supplier-Admin') || checkRole()". Still it doesn't work.
– Vaibhav27
Nov 19 '18 at 21:16
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
ng-disabled="(user.role=='Super-Admin' || user.role== 'Supplier-Admin') || checkRole()"
– Kurohige
Nov 19 '18 at 21:30
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
Got it. Tysm. It works.
– Vaibhav27
Nov 19 '18 at 22:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381369%2fhow-do-i-disable-buttons-on-a-specific-row-in-a-table-angular-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
don't use a function to do this; the function will be called every time the DOM is updated, and cause slowdowns. Add a property to the user to check against instead.
– Claies
Nov 19 '18 at 19:37
Can you please explain how to do this?
– Vaibhav27
Nov 19 '18 at 19:38