zoukankan      html  css  js  c++  java
  • 转帖:vs2008使用jquery智能提示

    Rich IntelliSense for jQuery

    Update: A new Hotfix is availble to complement this file.

    A while back we updated VS2008 IntelliSense to not fail when referencing jQuery.  However, getting IntelliSense for chained calls and rich summary/parameter hints still required adding special comments to a few thousand lines of jQuery.  If you didn't have the time, you could download such a file from friendly members of the community such as James and Brennan.

    As part of our new partnership with jQuery, yesterday we announced the availability of the official IntelliSense documentation file.  As you can see, our friends at jQuery have added a new download link for Visual Studio at http://docs.jquery.com/Downloading_jQuery#Download_jQuery.

    image

    You can also download the file directly from http://code.jquery.com/jquery-1.2.6-vsdoc.js.  As you might guess, this documentation file corresponds with the latest version of jQuery (which is currently 1.2.6).  While this file has a "js" extension, it's really just a documentation file.  You do not want to run this file in the browser.

    How do I use this file (today)?

    If you're inside an ASPX page, you will need to add the following lines of code into (normally) the head of your page:

    image

    Why do we have a server-side conditional statement?  IntelliSense disregards conditional statements of this type, and thus loads the "vsdoc" file (overriding the normal one).  At runtime the if (false) statement will ensure it this documentation file is not rendered (and executed) as script.  This trick allows the "switching" behavior you want.

    If you're in a JavaScript file, use the normal file reference syntax to refer to the "vsdoc" file.

    image

    There's no need for tricks here since this comment is only meaningful to IntelliSense.

    How do I use this file (in the near future)?

    The ideal user experience should be one where you do not need special tricks as mentioned above.  Really, you shouldn't need to mention the "vsdoc" file name at all.  To that end, we plan on releasing a Hotfix that will enable this (stay tuned!).  Given normal references such as...

    image image

    ...IntelliSense will opportunistically search for "jquery-1.2.6-vsdoc.js" and load that file instead.  Generally, given script name "x", IntelliSense will opportunistically search for "x-vsdoc.js".  If not found, it will then search for "x.debug.js".  You just need to make sure to place your "vsdoc" file next to the normal file.  Note, if you use jquery-1.2.6.min.js, you may need to rename the file to match the search pattern.

    What are the advantages of this file?

    One unique benefit of the file we have released is that it supports and understands jQuery plug-ins.  For example, given the plug-in below...

    image

    ...you would see "myplugin" show up in IntelliSense.

    image

    We've noticed a few plug-ins do not work, and commonly this is because there is an IntelliSense incompatibility issue with the plug-in itself (as opposed to the jQuery documentation file).

    Hope this helps!

    Jeff King
    Program Manager
    Visual Studio Web Tools

  • 相关阅读:
    自动化框架总结-2(转)
    svn离线安装以及配置,管理python自动化脚本
    自动化框架总结-1(转)
    pytest参数化、标记用例、生成html报告
    pytest作为前置和后置的使用
    笔记:常用xpath
    read_ini.py
    深入理解python类装饰器和带参数装饰器
    Python 03-Python3基础语法
    Python 02-Python2.x与3.x版本区别
  • 原文地址:https://www.cnblogs.com/LifelongLearning/p/1427566.html
Copyright © 2011-2022 走看看