本文介绍了单击后退按钮时,jQuery的按钮()会导致白屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我更新通过AJAX一些按钮列表。我的功能可在一般正常,但是这一段时间后产生白色屏幕。这发生在我点击按钮,然后使用后退按钮,并重复了几次。当我刷新约10个按键被设置在运行时使用AJAX的是,它的一些点击之后崩溃。当我刷新比方说20个按键,它会立即崩溃第一次我打的后退按钮。该LogCat中并没有说由当时的应用程序崩溃什么。我试图取代按钮()用的liveQuery调用它的作品,但经过一段时间后会产生相同的崩溃调用。

我正在开发一个原生应用。如果我尝试,因为在Firefox web应用程序,它完全没有崩溃。

我不知道如果我的问题有什么关系可用内存。我用三星Galaxy王牌其中有大约测试。 50 MB内存,并留下一个1 GB的SD卡。

  $(。warenkorb_class)。点击(函数(五){
      e.stopImmediatePropagation();
      亦即preventDefault();
      $。员额(的http://mydomain/backend.php,{
            动作:warenkorb,kunden_id:$ local_kunden_id},
            功能(数据){
        $ .mobile.changePage(#warenkorb);
        $(#warenliste)的html(数据);
            $(#warenliste)列表视图(刷新)。
            $(。warenliste_button_class)按钮();
        },HTML);
      });

我是新的android开发,我一直有这个问题了几天现在挣扎,会很高兴,如果有人可以帮助我在此。

感谢和问候,
弗洛里安

编辑:
下面是创建了按钮code backend.php部分:

 回声< TR>中;
回声utf8_en code(< TD><'delete_buttonHREF ='#warenkorb数据角色=按钮数据图标类= ='删除'数据iconpos ='NOTEXT数据小=真正的数据内嵌=真实数据主题='b'ID ='$ 1_ bestellungen_id'&GT​​;位置löschen< / A>< / TD>中);
回声utf8_en code(< TD><一类='minus_buttonHREF ='#warenkorb数据角色=按钮数据图标='减'的数据iconpos ='NOTEXT数据小=真正的数据内嵌=真实数据主题='b'ID ='$ 2_ bestellungen_id'&GT​​; EINS weniger< / A>< / TD>中);
回声&所述; TD>&下;一类='warenliste_button'的href ='#warenkorb'的id ='3_ $ bestellungen_id'数据迷你=真> $ bestellungen_anzahl&下; / A>&下; / TD>中;
回声utf8_en code(< TD><一类='plus_buttonHREF ='#warenkorb数据角色=按钮数据图标='加'数据iconpos ='NOTEXT数据小=真正的数据内嵌=真实数据主题='b'ID ='$ 4_ bestellungen_id'&GT​​; EINS梅尔< / A>< / TD>中);
回声utf8_en code(< TD><一类='warenliste_buttonHREF ='#warenkorb'ID ='5_ $ bestellungen_id数据迷你=真实数据内嵌='真'> $ produkte_bezeichnung&所述; / A>&下; / TD>中);
回声< / TR>中;


解决方案

我想看看优化您的code,尽量去除类选择和ID选择取代他们,这是不是更多钞票更具体在你选择做即button.warenliste_button_class。

我要排序,作为崩溃可能是由于脚本运行内存执行时。另外结账萤火/控制台检查ANS看看发生了什么,检查长时间运行脚本,大量的数据被张贴等。

看看这个链接更多优化提示

没有更喜欢的功能和数据的jQuery是正在操作我没有更多的建议信息。

I'm updating a list with some buttons via AJAX. My function works fine in general, however it produces a white screen after a while. This happens when I click the button and use the back button and repeat it a few times. When I refresh about 10 buttons that are provided on runtime with AJAX, it crashes after some clicks. When I refresh let's say 20 buttons, it crashes immediately the first time I hit the back button. The LogCat doesn't say anything by the time the app crashes. I tried to substituted the button() call with a livequery call which works but produces the same crash after some time.

I'm developing a native app. If I try it as a web-app in Firefox, it works perfectly without crashing.

I'm not sure if my problem has anything to do with the available memory. I'm testing with a Samsung Galaxy Ace which has approx. 50 MB internal memory left and a 1 GB SD card.

$(".warenkorb_class").click(function(e) {
      e.stopImmediatePropagation();
      e.preventDefault();
      $.post("http://mydomain/backend.php",{
            action: "warenkorb", kunden_id: $local_kunden_id },
            function(data) {
        $.mobile.changePage("#warenkorb");
        $("#warenliste").html(data);
            $("#warenliste").listview("refresh");
            $(".warenliste_button_class").button();
        }, "html");
      });

I'm new to android development and I've been struggling with this problem for some days now and would be very happy if someone could help me on this.

Thanks and regards,Florian

EDIT:Here is the part of backend.php where the code for the buttons is created:

echo"<tr>";
echo utf8_encode("<td><a class='delete_button' href='#warenkorb' data-role='button' data-icon='delete' data-iconpos='notext' data-mini='true' data-inline='true' data-theme='b' id='1_$bestellungen_id'>Position löschen</a></td>");
echo utf8_encode("<td><a class='minus_button' href='#warenkorb' data-role='button' data-icon='minus' data-iconpos='notext' data-mini='true' data-inline='true' data-theme='b' id='2_$bestellungen_id'>eins weniger</a></td>");
echo"<td><a class='warenliste_button' href='#warenkorb' id='3_$bestellungen_id' data-mini='true'>$bestellungen_anzahl</a></td>";
echo utf8_encode("<td><a class='plus_button' href='#warenkorb' data-role='button' data-icon='plus' data-iconpos='notext' data-mini='true' data-inline='true' data-theme='b' id='4_$bestellungen_id'>eins mehr</a></td>");
echo utf8_encode("<td><a class='warenliste_button' href='#warenkorb' id='5_$bestellungen_id' data-mini='true' data-inline='true'>$produkte_bezeichnung</a></td>");
echo "</tr>";
解决方案

I would have a look at optimising your code, try to remove the class selectors and replace them with id selectors, it that is not posible be more specific in your selector ie do button.warenliste_button_class.

I would sort that as the crashing could be due to script running out of memory while it is executing. Also checkout firebug/console to check ans see what is happening, Check for long running scripts, large amounts of data being posted etc.

Check out this link for more optimisation tips

http://www.archer-group.com/2011/technology/jquery-javascript-optimization

without more information like the functions and data that the jquery is being operated on i have no more suggestions.

这篇关于单击后退按钮时,jQuery的按钮()会导致白屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:37