Tern & jQuery support

Angelo edited this page Sep 9, 2015 · 12 revisions

tern.js provides the jquery JSON Type Definition which gives a support for jQuery.

After installing and converting your project as Tern Project, go at Tern project property, click on Tern / Modules item and select the jquery tern JSON Type Definition :

Check jQuery Def

After that you can benefit with jQuery completion on $ :

jQuery

This feature is based only with just this simple JSON definition :

"jQuery": {
    "!type": "fn(selector: string, context: frameElement) -> jQuery.fn",
    "!url": "http://api.jquery.com/jquery/",
    "!doc": "Return a collection of matched elements either found in the DOM based on passed argument(s) or created by passing an HTML string.",
    ...

Completion works for jQuery method :

jQuery

This feature is based only with just this simple JSON definition :

"on": {
        "!type": "fn(events: string, selector?: string, data?: ?, handler: fn(+jQuery.Event)) -> jQuery.fn",
        "!url": "http://api.jquery.com/on/",
        "!doc": "Attach an event handler function for one or more events to the selected elements."
      },
...

Tern is able to manage jQuery Event :

jQuery

This feature is based only with just this simple JSON definition :

"Event": {
      "!type": "fn(type: ?, props?: ?) -> +jQuery.Event",
      "!url": "http://api.jquery.com/category/events/event-object/",
      "!doc": "The jQuery.Event constructor is exposed and can be used when calling trigger. The new operator is optional.",
      "prototype": {
        "currentTarget":{
          "!type": "+Element",
          "!url": "http://api.jquery.com/event.currentTarget/",
          "!doc": "The current DOM element within the event bubbling phase."
        },
...
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.