Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141762 | Jan 3,2019 03:16 AM UTC | Jan 4,2019 06:12 AM UTC | ASP.NET MVC - EJ 2 | 3 |
![]() |
Tags: Switch |
<label for="unchecked" style="padding: 10px 24px 10px 0"> 1 minutes refresh </label>
@Html.EJS().Switch("unchecked").Change("setRe").EnablePersistence(true).Render()
<script type="text/javascript">
var interval;
//To relod the page based on setinterval.
function doit() {
clearInterval(interval);
if (window.location.reload)
window.location.reload(true);
}
//Will trigger on page reload.
function reloadpage() {
//To get the instance of switch component
var instance = ej.base.getComponent(document.querySelector("#switch"), 'switch');
if (instance.checked) {
interval = setInterval(doit, 60000);
}
}
//This function will trigger while changing state in switch.
function setRe(val) {
if (val.checked) {
interval = setInterval(doit, 60000);
}
else {
clearInterval(interval);
}
}
onload = reloadpage;
</script> |
<label for="switch" style="padding: 10px 24px 10px 0"> 1 minutes refresh </label>
@Html.EJS().Switch("switch").Change("setRe").EnablePersistence(true).Render()
<script type="text/javascript">
//..
//Will trigger on page reload.
function reloadpage() {
//To get the instance of switch component
var instance = ej.base.getComponent(document.querySelector("#switch"), 'switch');
if (instance.checked) {
interval = setInterval(doit, 60000);
}
}
//..
</script>
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.