views:

141

answers:

1

Hi All,

Can anyone tell em how can call a function with parameters on a dialog and call that same function from somwhere else also.

function  showEditDialog(TagDivId, id, type, bFlag)

{ try { stickyinfo = new Array(); jQuery('#'+TagDivId).dialog({

    autoOpen: false,
    height : 535,
    width:320,
    modal: true,
    resizable:false,
    //closeOnEscape:false,

    buttons: {
        Cancel: function() {
            jQuery(this).dialog('close');
        },
        'OK': function showEditDialogOkFunc(id) {
   //stickyinfo.clear();
            //Register Collaboba Tag with the Server.
   var color = jQuery('#' + id).css('background-color');
   var tagid = document.getElementById(id);
   if(tagid != null)
   {
                GetTagInformation(id, stickyinfo); 
   }
   else
   {
    return false;
   }
             }
       }

            catch(e)
            {
           alert(e);
            }
   }

Is it ok the way i m calling showEditDialogOkFunc(id) and can i call this function from anywhere else.Since it's a dialog function will it get all the properies of the dialog defined above the ok function.And if i call the OK function from anuwhere else will it get all the properties of the dialog o not. Thanks

A: 

try this example:

function showEditDialogOkFunc(opcions)
{
    alert(opcions.id + " " + opcions.stickyinfo);
}


function  showEditDialog(TagDivId, id, type, bFlag) {

  var options = {
     id:id,
     stickyinfo: new Array()
  }
  var pthis = this;

  ...
  'OK': function () { showEditDialogOkFunc.call(pthis, options) }
  ...

}
andres descalzo