更新动态滑出

PhoneJs: update dynamically slideout

本文关键字:动态 更新      更新时间:2023-09-26

我想从数据库(websql)中更新幻灯片中的特定字段,以显示当前用户,他可以访问他的配置文件。目标是:title: log1,为此我使用了save:function (),并且在数据库中有一条记录。我花了很多天寻找,但直到现在还没有答案。有人能帮帮忙吗?

//...
    <script type="text/javascript">
        $(function() {
            slideOut.app.navigate();
        });
        slideOut.Home = function (params) {        
            return {};
        };
    </script>

</head>
<body>

    <div data-options="dxView : { name: 'Home', title: 'Slide Out' } " >
    <div data-options="dxContent : { targetPlaceholder: 'content' } " >
    </div>
</div>

</body>
</html>

App.config:

window.slideOut = $.extend(true, window.slideOut, {
var log1;
save:function (){
    var db = openDatabase("dossierpatient", "1.0", "BD patient", 32678);
    db.transaction(function(transaction){
    transaction.executeSql("SELECT * FROM patient;", [], function(transaction,result){
                            for (var i=0; i< result.rows.length; i++) {
                                log1 = result.rows.item(i).login;
                                console.log(log1 + "'n ");
                            }
                        });
});
return log1;
}
  "config": {
    "navigationType": "slideout",
    "navigation": [
      {
        "title": log1,
        "action": "#",
        "icon": "todo"
      },
      {
        "title": "Item 2",
        "action": "#",
        "icon": "tips"
      },
      {
        "title": "Item 3",
        "action": "#",
        "icon": "card"
      },
      {
        "title": "Item 4",
        "action": "#",
        "icon": "map"
      }
    ]
  }
});

app.js

window.slideOut = window.slideOut || {};
$(function() {
    // Uncomment the line below to disable platform-specific look and feel and to use the Generic theme for all devices
    // DevExpress.devices.current({ platform: "generic" });
    slideOut.app = new DevExpress.framework.html.HtmlApplication({
        namespace: slideOut,
        commandMapping: slideOut.config.commandMapping,
        navigationType: "slideout",
        navigation: getNavigationItems()
    });
    slideOut.app.router.register(":view", { view: "Home"});

    function getNavigationItems() {
        return slideOut.config.navigation; // cherche le contenu du slideOut
    }
});

似乎你在app.config.js中有一个错误。var log1的声明应该在扩展代码之上。美元的。Extend应该有参数作为有效的js对象:

var log1;
$.extend(true, window.slideOut, {
    save: ...,
    ...
}
我不建议你在应用配置文件中添加这样的代码。要自定义视图标题(或视图中的任何内容),请使用带有可观察对象的viewModel。例如:
slideOut.Home = function (params) {
    var title = ko.observable("title");
    var viewModel = {
        title: title,
        viewShowing: function() {
            // TODO: put code fetching title from db and set it on done to observable
            title("value");
        }
    };
    return viewModel;
};

以上代码将设置视图的标题