Javascript 如何记住Crossrider中弹出窗口的状态?

Javascript 如何记住Crossrider中弹出窗口的状态?,javascript,jquery,popup,crossrider,Javascript,Jquery,Popup,Crossrider,我在Crossrider中有一个弹出窗口,其中有一个复选框。它看起来像这样: popup.html <body> <div data-role="page" id="div1"> <label for="checkbox1">Enable Something</label> <input type="checkbox" id="checkbox1"> </div> </b

我在Crossrider中有一个弹出窗口,其中有一个复选框。它看起来像这样:

popup.html

<body>
    <div data-role="page" id="div1">
        <label for="checkbox1">Enable Something</label>
        <input type="checkbox" id="checkbox1">
    </div>
</body>
正确的方法是什么


谢谢你

在调用弹出窗口之间不保留弹出窗口内容;因此,您必须将状态保存在弹出范围之外,通常用于Crossrider数据库中的少量数据,例如

此外,此类代码最好放在crossriderMain函数中,该函数在页面准备就绪时自动调用

例如:

<!DOCTYPE html>
<html>
<head>
<!-- This meta tag is relevant only for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">
function crossriderMain($) {
  if (appAPI.db.get('checkbox1'))
    $('#checkbox1').prop('checked', true);    
  else
    $('#checkbox1').prop('checked', false);

  $('#checkbox1').on('change', function(){
    appAPI.db.set('checkbox1', $(this).is(':checked'));
  })
}
</script>
</head>
<body>
  <div data-role="page" id="div1">
    <label for="checkbox1">Enable Something</label>
    <input type="checkbox" id="checkbox1">
  </div>
</body>
</html>

函数crossriderMain($){
if(appAPI.db.get('checkbox1'))
$('#checkbox1').prop('checked',true);
其他的
$('checkbox1').prop('checked',false);
$('#checkbox1')。在('change',function()上{
appAPI.db.set('checkbox1',$(this).is(':checked');
})
}
促成某事
[披露:我是一名交叉骑手员工]

<!DOCTYPE html>
<html>
<head>
<!-- This meta tag is relevant only for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">
function crossriderMain($) {
  if (appAPI.db.get('checkbox1'))
    $('#checkbox1').prop('checked', true);    
  else
    $('#checkbox1').prop('checked', false);

  $('#checkbox1').on('change', function(){
    appAPI.db.set('checkbox1', $(this).is(':checked'));
  })
}
</script>
</head>
<body>
  <div data-role="page" id="div1">
    <label for="checkbox1">Enable Something</label>
    <input type="checkbox" id="checkbox1">
  </div>
</body>
</html>