csdn产品小助手 2016-04-05 11:44 采纳率: 0%
浏览 30

jQuery:删除页面

I'm using jQuery mobile and my page is generated from an index.php file. When I click on links referring to another option of my php file (index.php?action=other_action) it loads in Ajax so the previous content is still kept in the code. This causes problems as nothing is dynamic anymore, because I'm using specific ids, so it breaks everything. Of course disabling Ajax works but I loose all the beauty of jQuery Mobile.

I guess a solution would be to create an onclick function on the <a>, that will prevent the page from keeping the previous content or delete the old page.

So is there a way to keep using ajax in a way that it doesn't break my dynamic elements ?

You can see it in action here, you can filter names if everything's good. Then click on the top left panel and click something, notice what happens in the inspector...

Thanks for any help.

  • 写回答

2条回答 默认 最新

  • ?yb? 2016-04-05 14:07
    关注

    Hi you have missed enclosing the selector within qoutes...

    your jQuery

    $(document).ready(function() {
       //bind a listener to "click" event on links with class "markviewed"
       $('a.ui-btn-present').click(function(event) {
        $('ul.listlist').listview('refresh');
    

    $(#pageone).remove(); //<-- selector should be within quotes

    // get ids from clicked <a>
       var id = $(this).attr('data-id');
       $(this).attr({
                "class" : "ui-btn ui-btn-icon-notext-ok ui-icon-check ui-btn-a"
            });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘