I am trying to work out the position and the height/width of a DOM element through TypeScript/JQuery. Before TypeScript I simply did something like this:
function ActOnClick(itemClicked, loadPath) {
//sample code
var v1 = itemClicked.offset();
var v2 = itemClicked.width();
var v3 = itemClicked.height();
};
$(document).ready(function () {
$("#idCRM").click(function () {
ActOnClick($("#idCRM"), "/Widgets/GetCRM");
});
}
where idCRM is a 'section' in my cshtml document (but it could be any div etc.)
Now I am trying to move this code into TypeScript but what type do I expect in the ActOnClick function to come in from the jQuery's $("#idCRM")? Right now I choose 'Element' but a) it doesn't expose width, height etc and b) the ActOnClick call fails caused by the $("#idCRM")!
/// <reference path="../../ScriptsTS/jquery.d.ts" />
function ActOnClick(itemClicked: Element, loadPath: string) {
var v1 = itemClicked.offset(); <-- FAILS
var v2 = itemClicked.width(); <-- FAILS
var v3 = itemClicked.height(); <-- FAILS
};
$(document).ready(function () {
$("#idCRM").click(function () {
ActOnClick($("#idCRM"), "/Widgets/GetCRM"); <-- FAILS
});
}