0

How i verify if my callBackFunction is defined as a function with jquery?

var callBackFunction =window['columnActive'];
(...)
            "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                if ($.isFunction(callBackFunction)) {
                    alert('cheguei');
                    columnActive(nRow, aData, iDisplayIndex, iDisplayIndexFull);
                }

        }
Fabio Santos
  • 253
  • 1
  • 4
  • 15

1 Answers1

3

You don't need jQuery for this, the built-in (and globally supported) typeof operator will tell you:

if (typeof callBackFunction === 'function')

typeof also works even if callBackFunction was never defined or declared, while jQuery and others will throw an error if you call $.isFunction(x) and x was never declared.

ssube
  • 47,010
  • 7
  • 103
  • 140