重新加载页面并转到以前活动的选项卡php jquery-jtable

时间:2014-10-25 00:02:23

标签: javascript php jquery jquery-ui jquery-jtable

我想在用户点击submit表单上的jquery-jtable按钮后重新加载页面并导航到用户之前处于活动状态的标签页。我现在重新加载页面,但在重新加载之前没有导航到用户的最后一个活动选项卡。选项卡使用jquery ui创建。这是缩短的html:

    <div id="tabs">
            <ul>
                <li><a href='#tabs-TasksWithRisks'>Tasks With Risks</a></li>
                <li><a href='#tabs-Lessons-Learned'>Lessons Learned</a></li>
            </ul>

           <div id='tabs-TasksWithRisks' class='tab'>
                <div id="TasksWithRisksTableContainer" class="jTableContainer" style="width:100%;"></div>
            </div>
            <div id='tabs-Lessons-Learned' class='tab'>
                <div id="LessonsLearnedTableContainer" class="jTableContainer" style="width:100%;"></div>
            </div>            
     </div>

<script type="text/javascript">
    var project_id = <?php echo $project_data['project_id']; ?>;
    var modify = <?php echo $modify ? 'true' : 'false'; ?>;
    $(document).ready(function() {
        loadViewProjectTasksWithRisksTable('TasksWithRisksTableContainer', project_id, modify);
        loadViewLessonsLearnedTable('LessonsLearnedTableContainer', project_id, modify);
</script>

function loadViewLessonsLearnedTable(ContainerID, project_id, modify, no_toolbar) {
    var fields = $.extend(true, fields, LessonsLearnedFields); //copy, don't reference
    fields.Responses = getLessonsLearnedResponseChildTable(ContainerID);
    $('#' + ContainerID).jtable({
        title: 'Lessons Learned',
        paging: true,
        pageSize: 100,
        sorting: true,
        defaultSorting: 'WBS ASC',
        actions: {
            listAction: config.base_url + 'data_fetch/risks_cause_by_project/' + project_id,
            deleteAction: config.base_url + 'data_fetch/delete_risk/',
            updateAction: config.base_url + 'data_fetch/update_lessons_learned_risk/' + project_id 
        },
        messages: defaultRiskMessages,
        fields: fields,        ,
        formSubmitting: function(event,data){
            $('select[name=cause]', data.form).attr('name','cause[]');
            location.reload(true);
            return data;
        }
    });
    $('#' + ContainerID).jtable('load');
}

我累了location.href = config.base_url + '#tabs-Lessons-Learned';但这没用。我在网上找到的大多数工作解决方案都是用于引导程序,所以它们没有多大帮助。

我找到this question on stackoveflow,但我无法根据自己的需要定制答案。

非常感谢所有帮助。

1 个答案:

答案 0 :(得分:0)

而不是location.reload(true);我使用了loaction.assign('address_I_wanted_to_go_to')