2014-03-25 66 views
0

我想從數據庫(websql)的slideout中更新一個特定的字段,以顯示當前用戶,他可以訪問他的profil。 目標是:title: log1,對於我使用save:function(),我有一個記錄在數據庫中。 我花了很多天搜索,但直到現在沒有解決方案。 有人可以幫忙。PhoneJs:更新動態滑出

指數

//... 
    <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 
    } 

}); 

回答

0

好像你在app.co錯誤nfig.js. var log1的聲明應該在擴展代碼之上。在$ .extend應該有參數,有效的JS對象:

var log1; 

$.extend(true, window.slideOut, { 
    save: ..., 
    ... 
} 

搬過來,我不會建議你在應用程序配置文件中添加這樣的代碼。 要自定義視圖標題(或您在視圖中擁有的任何視圖),請使用帶有observables的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; 
}; 

上面的代碼將設置視圖的標題。