いろいろ試した結果、いくつかの発見を纏める。
・checkboxをlabelの中に入れると、visible bindingが効かなくなる
・「$index」そのまま使うと、文字列操作の式でfunctionの文字列が使われる。0からの値で利用したい場合は「$index()」を使う
JS
var appViewModel = { cards: ko.observableArray([]),
addMode: ko.observable(false)};
ko.applyBindings(appViewModel);
HTML
<ul data-role="listview" id="card_list" data-inset="true" data-bind="foreach: cards">
<li>
<a href="#">
<input type="checkbox" name ="card-to-add"
data-bind="visible: $root.addMode,
attr: {id: 'checkbox-'+$index()}">
<label data-bind="attr: {for: 'checkbox-'+$index()}">
<span data-bind="text: CARDNAME"></span>
</label>
</a>
</li>
</ul>
2014年6月10日火曜日
2014年6月9日月曜日
jquery mobileのcheckboxを選択できる状態にする
jquery mobileを使って、JSで動的にcheckboxを追加しても、クリックしても何も反応はない。そこで、以下のJSを挿入することで解決できた。
$("[type=checkbox]").checkboxradio(); //add this line to enable checkbox
$("[type=checkbox]").checkboxradio(); //add this line to enable checkbox
2014年5月14日水曜日
phonegap開発フロー
開発フロー
cordova create pg_triplan com.caihongtown.trip "trip plan"
cd
pg_triplan
cordova platform add android
cordova build
emulatorを起動後
cordova emulate android
cordova run android(端末にインストール)
pluginの管理
cordova plugin
(
インストールしたpluginの表示)
cordova plugin search KEYWORD(使用できるpluginの検索)
cordova plugin add org.apache.cordova.inappbrowser(追加)
cordova plugin rm org.apache.cordova.console(削除)
2014年5月7日水曜日
phonegapをブラウザーでデバッグ
jsがブラウザーでデバッグできると便利。phonegap desktopは実現してくれる。
https://github.com/jxp/phonegap-desktop
使い方:
1)Copy debugdata.json into the root www folder of the project
2)Use the phonegap-desktop.js in place of the standard phone gap library
3)web serverを起動。pythonを利用すれば便利。python -m SimpleHTTPServer 8080
4)そして http://localhost:8080/ にアクセス
2014年5月6日火曜日
UPDATE column from other columns
sql serverにLATとLNGをfloatとして保存した。位置情報をNULLになっていたGPSLOCに保存したい。
update [dbo].SHOPINFO
set GPSLOC = geography::Point(LAT,LNG,4326)
GO
update [dbo].SHOPINFO
set GPSLOC = geography::Point(LAT,LNG,4326)
GO
2014年5月2日金曜日
SSMS経由でExcelデータをAzure SQLへインポート
2つテクニックがあります。
1)データインポートのメニューを出すために、ローカルDBに接続し、そのDBの名前を右クリックすると、「タスク→データのインポート」選択できる。その後、変換先のサーバー名をAzure SQLを指定すれば良い。
2)Azure SQLのテーブルには、[id]列は必須です。「マッピングの編集→SQLの編集」で
「[id] int identity primary key,」を追加。
詳細な操作は下記ビデオをご覧ください。
http://www.youtube.com/watch?v=QAd2uAGNHPw
1)データインポートのメニューを出すために、ローカルDBに接続し、そのDBの名前を右クリックすると、「タスク→データのインポート」選択できる。その後、変換先のサーバー名をAzure SQLを指定すれば良い。
2)Azure SQLのテーブルには、[id]列は必須です。「マッピングの編集→SQLの編集」で
「[id] int identity primary key,」を追加。
詳細な操作は下記ビデオをご覧ください。
http://www.youtube.com/watch?v=QAd2uAGNHPw
2014年4月11日金曜日
Azure sql server上保存された場所を現在地からの距離順で表示
Azure sql serverのtableに場所名とその位置情報を保存している。
現在地からの距離順で場所を表示させる方法。
Azure mobile serviceのtableスクリプトを利用する。
読み取り操作に、以下のスクリプトを入れる。
requestのパラメータとして、現在地の経度と緯度をserver scriptに渡す。
SHOPINFOのGPSLOC列から位置情報を取り出し、距離を計算する。
function read(query, user, request) {
var lat = request.parameters.lat;
var lng = request.parameters.lng;
var sql = "DECLARE @g geography;"+
"SET @g = geography::Point(?,?, 4326);"+
"SELECT *,round(@g.STDistance(GPSLOC),0) as DIST from [dbo].SHOPINFO order by DIST;"
mssql.query(sql,[lat,lng],{success: function(results) {
request.respond(200,results);
}
})
}
アプリから、get methodで以下のURLにアクセスする。
https://abcdef.azure-mobile.net/tables/shopinfo?lat=latitudeFromGps&lng=longitudeFromGps
参考になったページ:http://hatsune.hatenablog.jp/entry/2014/02/06/092155
現在地からの距離順で場所を表示させる方法。
Azure mobile serviceのtableスクリプトを利用する。
読み取り操作に、以下のスクリプトを入れる。
requestのパラメータとして、現在地の経度と緯度をserver scriptに渡す。
SHOPINFOのGPSLOC列から位置情報を取り出し、距離を計算する。
function read(query, user, request) {
var lat = request.parameters.lat;
var lng = request.parameters.lng;
var sql = "DECLARE @g geography;"+
"SET @g = geography::Point(?,?, 4326);"+
"SELECT *,round(@g.STDistance(GPSLOC),0) as DIST from [dbo].SHOPINFO order by DIST;"
mssql.query(sql,[lat,lng],{success: function(results) {
request.respond(200,results);
}
})
}
アプリから、get methodで以下のURLにアクセスする。
https://abcdef.azure-mobile.net/tables/shopinfo?lat=latitudeFromGps&lng=longitudeFromGps
参考になったページ:http://hatsune.hatenablog.jp/entry/2014/02/06/092155
登録:
投稿 (Atom)