【问题标题】:Enabling a button on another page启用另一个页面上的按钮
【发布时间】:2012-02-27 11:21:18
【问题描述】:

所以我有例如 2 个页面(jquery mobile),所以不同的页面实际上是同一个 html 中的 div。所以我所拥有的是第 3 页,它从数据库加载图像,当您单击图像时,它会转到第 #2 页并将图像放在该第 #2 页上的 div 中。现在我有一个禁用=“禁用”的按钮。当调用该函数将图像放入该页面#two div 时,它会自动重定向到页面#two。现在按钮本身被禁用。于是我尝试在添加图片的功能中加入这个:document.getElementById("resetbutton").disabled = false;

当页面再次重定向回页面 #two 时会发生这种情况,按钮会重新加载,因此会覆盖禁用的 false,因为它会自动禁用。这个问题有什么解决办法?

提前致谢!

【问题讨论】:

  • 调用 document.getElementById("resetbutton").disabled = false; 时绑定到哪个事件你能发布一些示例代码吗?
  • 点击图片时调用 opslaan() 函数。
  • 函数 opslaan(hetPad) { $('div#content2').append('
    ' ); window.location = '#two'; window.getElementById("resetbutton").disabled = false; }
  • 你为什么打电话给 window.location = '#two'; ?不能用jqm的changePage()吗?

标签: javascript jquery mobile jquery-mobile


【解决方案1】:

你不能这样做吗:

$('#two').live('pageinit',function(event){
    if (resetButton) { // variable to determine active/disabled
        $('#resetbutton').addClass('active');
    }
});

我认为您可以简单地调用 ('#resetbutton').addClass('active'); (类似于您正在执行的操作)在函数中...您是否在第 2 页上动态生成该内容?如果是这样,您应该能够绑定到 pageinit 或 pageshow 事件并确定按钮状态。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 2017-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多