小编mrp*_*per的帖子

提交按钮后再次调用 document.ready 函数?

在 doc.ready 中,我通过解析 html 表动态生成选择选项列表 -> selected_Test_Platforms 当我单击提交按钮时,我想提交所选选项并运行 main()

main() 函数做了很多计算,最后打印了一些谷歌图表。

每次我单击“提交”按钮时,main() 函数都会正确执行,但不久之后 document.ready 函数也会被调用,并且所有内容都会被覆盖!

为什么我只想调用 main 却再次调用 document.ready 函数?

$(document).ready(function() {
//...
// ---------------------------------------------------------------------//
// find Affected TestPlatforms and add them to the selector
// ---------------------------------------------------------------------//
    $('tbody tr').each(function() {
        var TestPlatform = $(this).find('td.Affected').text(); //Affected Test Platforms
        aquireTestPlatforms(TestPlatform);
    });
    addTestPlatformsToSelector();
});

function main(){

//...multiple lines of calculation...

// example of one Chart
    google.charts.setOnLoadCallback(drawSOWCoverageChart);
    function drawSOWCoverageChart(){
    
        var data = google.visualization.arrayToDataTable([
            ['Type', 'Count'],
            ['Positive Tested and Tested with Restrictions', posSOWTestCoverage],
            ['other …
Run Code Online (Sandbox Code Playgroud)

javascript jquery document-ready

1
推荐指数
1
解决办法
4986
查看次数

标签 统计

document-ready ×1

javascript ×1

jquery ×1