0
這是通過Lightswitch HTML客戶端的jscript 相同的例程可以很好地從Button調用,但調用失敗來自Canvas事件,顯示未定義的數據錯誤。相同的數據例程「CalcPrecio」可以正常從按鈕調用,但在從Canvas事件中調用時在Lightswitch HTML客戶端中斷開
// Creates a Canvas and add an eventlistner Works fine
myapp.AddEditLito.Montajes_render = function (element, contentItem) {
var itemTemplate = $("<canvas id='myCanvas' width='600' height='150'></canvas>");
var canvas = myCanvas;
myCanvas.addEventListener('mousedown', function (event) {
var context = canvas.getContext('2d');
DibTriangulo(screen, 50); // Draws a triangle, everything fine until here
// here is the problem,
CalcPrecio(screen, 1); // breaks with "Undefined Data.. etc."
}, false);
};
// Called from a Button, same routine works perfect!!
myapp.AddEditLito.Button1_execute = function (screen) {
CalcPrecio(screen, 1); // Works fine
};
// This routine Works perfect called from a button, but fails when called from a Canvas event!
function CalcPrecio(screen, col) {
$.each(screen.Liquidas.data, function (i, p) {
p.valor = p.cantidad * p.unitario;
});
};
//我做錯了什麼? Heeeelp!