简体   繁体   English

如何更改代码以便执行?

[英]How can I change the code so that it can execute?

I use jQuery to develop mobile applications. 我使用jQuery开发移动应用程序。 The problem is that when I add 5 or 6 lines to the page, all goes well, but if I add say 120 lines it displays an error message: Javascript execution exceeded timeout . 问题是,当我在页面上添加5或6行时,一切正常,但是如果添加120行,则会显示错误消息: Javascript execution exceeded timeout

function succes_recu_list_rubrique(tx, results) { //après avoir rempli sqlite
  console.log('ENTRééééééééééééééé---');
  $('#lbtn').prepend("<legend>Sélectionner une rubrique</legend><br>");
  for(var i=0; i<results.rows.length; i++) {
    //Remplir tableau liste des identifiants étapes
    $('#lbtn').append("<input name='opt1' checked type='radio' value="+results.rows.item(i).IdRubrique+" id="+results.rows.item(i).IdRubrique+" />");
    $('#lbtn').append('<label for='+results.rows.item(i).IdRubrique+'>'+results.rows.item(i).LibelleRubrique+'</label>');   
  }
  $('#lbtn').append('<a href="#page_dialog2" class="offer2" data-rel="dialog" data-role="button" >Consulter</a>').trigger('create');
  $('#lbtn').append('<a href="#'+id_grp_rub+'" data-role="button" data-rel="back" data-theme="c">Cancel</a>').trigger('create');
}

无需调用.append四个不同的时间,您可以一次将所有html放在一个字符串中,并在两个新创建的锚点上调用一个触发器。

Create a local variable for your selection: 创建一个本地变量供您选择:

var temp = $('#lbtn')

add all your lines to that variable 将所有行添加到该变量

temp += "code here";

etc. 等等

and then append to the element once. 然后一次附加到元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改此代码,以便我可以在同一页面上再次使用它 - How to change this code so I can use it again on the same page 如何等待变量具有值,以便我可以执行其他代码? - How to wait for a variable to have a value so I can execute other code? 如何更改我的代码,以便用户只能喜欢该帖子一次? - How can I change my code so that the user can only like the post once? 如何使用Mootools链接单击事件,以便它们按顺序执行? - How can I chain click events with Mootools so that they execute in order? 如何执行此AJAX / JSONP代码? - How can I execute this AJAX/JSONP code? 我如何更改 html 或 javascript 代码,所以当我单击 div 时,即使它不起作用。我该如何解决? - How can i change html or javascript code, so when i click divs even it doesnt work .How can I fix it? 当我更改到新页面时,如何执行特定代码? - How can I execute a specific code whenerver I change to a new page? 如何更改 html 快捷方式的默认值“!” 在 vsc 中? (这样我就可以添加更多的 html 代码) - How can I change the default of the html short-cut "!" in vsc ? (So that I can add more html code) 如何优化我的代码,使其可以有效运行? - How can I optimize my code so, it can run effectively? 如何减少此代码的javascript代码,使其不那么重复? - How can I reduce this code javascript code so it's not as repetitve?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM