如何在每次卡拖放动作后防止页面刷新? (SDK 2.0p5)

时间:2013-05-07 10:07:44

标签: rally

我有最简单的CardBoard实现:

<!DOCTYPE html>
<html>
<head>
    <title>CardBoard Example</title>

    <script type="text/javascript" src="/apps/2.0p5/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function() {
            Ext.define('CustomApp', {
                extend: 'Rally.app.App',

                launch: function() {
                    var cardBoardConfig = {
                        xtype: 'rallycardboard',
                        types: ['User Story'],
                        attribute: "ScheduleState"
                    };

                    this.add(cardBoardConfig);
                }
            });

            Rally.launchApp('CustomApp', {
                name: 'CardBoard Example'
            });
        });
    </script>

    <style type="text/css">
    </style>
</head>
<body></body>
</html>

每次拖放操作后都会出现非常恼人的问题:页面刷新。

此外,我注意到一些阻止页面重新加载的错误。重现的步骤:

  1. 打开上面代码的页面;
  2. 更改项目范围;
  3. 拖放卡;
  4. 您将在浏览器控制台中看到javascript错误,导致页面无法刷新。
  5. 如果没有javascript Rally SDK错误,如何在卡片拖放操作后阻止页面刷新?

2 个答案:

答案 0 :(得分:0)

这是由父窗口对objectUpdate message的处理不当造成的。删除卡后,objectUpdate消息将被(正确)触发,但自定义HTML面板会通过刷新应用程序来处理它。我已经向Rally提交了一个错误来修复它。

要覆盖此行为,请在Rally.onReady

之后添加此行为
if(window.parent) {
    window.parent.RALLY.ui.dashboard.PanelPanel.prototype.onObjectModificationMessage = function(){};
}

所以整个代码看起来像:

<!DOCTYPE html>
<html>
<head>
    <title>CardBoard Example</title>

    <script type="text/javascript" src="/apps/2.0p5/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function() {

            if(window.parent) {
                 window.parent.RALLY.ui.dashboard.PanelPanel.prototype.onObjectModificationMessage = function(){};
            }

            Ext.define('CustomApp', {
                extend: 'Rally.app.App',

                launch: function() {
                    var cardBoardConfig = {
                        xtype: 'rallycardboard',
                        types: ['User Story'],
                        attribute: "ScheduleState"
                    };

                    this.add(cardBoardConfig);
                }
            });

            Rally.launchApp('CustomApp', {
                name: 'CardBoard Example'
            });
        });
    </script>

    <style type="text/css">
    </style>
</head>
<body></body>
</html>

答案 1 :(得分:0)

这是一个类似的问题,答案稍有不同,对你也有用:

App works as desired in debug mode but crashes in Rally environment