简体   繁体   English

仅当Flexigrid最初运行时才重新加载Jquery Flexigrid

[英]Jquery Flexigrid reload only if flexigrid initially ran

I'm trying to use flexigrid to show results using the values from a form. 我正在尝试使用flexigrid使用表单中的值显示结果。 So when a person clicks a form I want it to load the flexigrid function if its the first time the person clicked the button to initialize the table. 因此,当某人单击表单时,如果该人第一次单击该按钮以初始化表格,我希望它加载flexigrid函数。 Then if someone adjusts the values in the form then clicks the button again it then reloads the flexigrid table with the new form values. 然后,如果有人调整了表单中的值,然后再次单击该按钮,那么它将使用新的表单值重新加载flexigrid表。 How can I do this in one function? 如何在一项功能中做到这一点? Right now I have the flexigrid code running on page load, then if they click the button it runs this: 现在,我有在页面加载时运行的flexigrid代码,然后如果他们单击按钮,它将运行此代码:

<script type="text/javascript">
$(function() {

$('#RunReport').click( function() {
    var report_name = $('input[name=report-name]').val();
    var report_cell = $('input[name=report-cell]').val();
    var query_url = encodeURI('name=' + report_name + '&cell=' + report_cell);
    $('#reporting').flexOptions({ url: '/report.php?' + query_url }).flexReload();
});

});
</script>

But instead of having it in both functions I wanted it all in one function only running the reload if flexigrid was already initialized. 但是,我希望不是在两个函数中都使用它,而是希望在一个函数中全部都使用,如果flexigrid已被初始化,则只运行重新加载。 Hope this makes sense, still new at all of this. 希望这是有道理的,但在所有这些方面仍然是新的。

<script type="text/javascript">

function runreport() {
    $('#RunReport').click( function() {
        var report_name = $('input[name=report-name]').val();
        var report_cell = $('input[name=report-cell]').val();
        var query_url = encodeURI('name=' + report_name + '&cell=' + report_cell);
        $('#reporting').flexOptions({ url: '/report.php?' + query_url }).flexReload();
    });
}

$(document).ready(function() {
    runreport();

    $('#RunReport').click( function() {
        runreport();
    });
});
</script>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM