What is the difference between jQuery and jQueryStatic interface in TypeScript?

Can someone explain this? I understand that the jQuery interface is the one that is predefined, but what is JQueryStatic?

I have the following:

(function($) { $.fn.disableBt = function() { $(this).attr('disabled', true); if ($.browser.msie && $.browser.version < 9) { $(this).addClass('disabled'); } } })(jQuery); 

The only way to get typescript to find out about this was to add it to the jQuery interface as follows:

  disableBt(); } 

I tried adding it to jQueryStatic, but it didn't seem to work:

 interface JQueryStatic { modal( options ); disableBt(); } 

Here, the method parameters are defined in my modal format:

 $.modal.defaults = { content: false, useIframe: false, ... ... var settings = $.extend({}, $.modal.defaults, options), 
+4
source share
1 answer

Are "parameters" defined (in modal (options))?

The jQueryStatic interface has static methods ("the ones related to $ and jQuery themselves")

The jQuery interface has elements that can be run on jQuery elements, many of which return jQuery for the chain.

 interface JQueryStatic { someAdditionalMethod(): any; } $.someAdditionalMethod(); interface JQuery { pluginMethod(): JQuery; } $("body").pluginMethod(); 

if your case looks something like this:

 interface ModalDefaultOptions { content?: bool; useIframe?: bool; } interface JQueryStatic { modal: { defaults: ModalDefaultOptions; }; } interface JQuery { disableBt(): void; // or :JQuery if you returned 'this' from the function } $("#someButton").disableBt(); $.modal.defaults.content = false; 
+6
source

Source: https://habr.com/ru/post/1442666/


All Articles