How can I define a jQuery object when I am using typescript ?

Topics: General
Oct 28, 2012 at 8:21 AM

My group is not very clear on how I can do this. Here's our code sample:


var modal = {
    content: '',
    form: '',
    $form: '',
    $message: '',
    $modal: '',
    $submits: '',
    href: ''

$.modal = function (options) {
    var settings = $.extend({}, $.modal.defaults, options),
        root = getModalDiv(),
    function getModalDiv() {
        var modal = $('#modal');
        return modal;

modal.$modal = $.modal({
    title: link.title,
    closeButton: true,
    content: modal.content,
    onClose: onModalClose,
    minWidth: 315,
    maxHeight: false,
    width: false,
    resizeOnLoad: true
modal.$form = modal.$modal.find('.form');

The problem here is we are not sure how to define $modal. Right now it's defined as a string which I know is not correct. As a result there's an error when the .find method is run against it. 

How can we correctly define $modal. 

Also the reason we are using the modal variable is that this is populated and used by the inner functions in our code. Is this still the best way to do this now we have started to use typescript or is there a better way to create an object that we can pass around?

Oct 29, 2012 at 6:09 PM

Hi RichardAlan,

If you don't get an answer here, an even better place for specific cases is our Q&A over at StackOverflow (  You might try asking again over there (if you haven't already).