七段

          無論怎樣,請讓我先感謝一下國家。

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            35 Posts :: 2 Stories :: 7 Comments :: 0 Trackbacks
          jQuery Common Coding tips:
          1, less code by chain coding
          2, Use data method instead of storing data inside the DOM.
              
           $('selector').data('meaningfullname', 'this is the data I am storing');
          // then later getting the data with
          $('selector').data('meaningfullname');

          3, If you are Manipulating the DOM a lot, use livequery.(1.3)
           
              $('div.edit').livequery('click', function(){
          //go into edit mode
          });

          4, Use classes as flags:With jQuery you can add a class with the addClass method and then check later if an element has the class with the hasClass method.
          5, use same function name to handle different arguments
          6, pass options for configuration data
          7, test your code by screw.unit
          8, make most jQuery code into resuable plugins

          jQuery plugin pattern tips:
          (from: http://www.learningjquery.com/2007/10/a-plugin-development-pattern)
             1.  Claim only a single name in the jQuery namespace
             2. Accept an options argument to control plugin behavior
             3. Provide public access to default plugin settings
             4. Provide public access to secondary functions (as applicable)
             5. Keep private functions private
             6. Support the Metadata Plugin

          已有 0 人發表留言,猛擊->>這里<<-參與討論


          JavaEye推薦




          文章來源:http://sevenduan.javaeye.com/blog/507354
          posted on 2009-10-31 14:49 sevenduan 閱讀(410) 評論(0)  編輯  收藏 所屬分類: JavaScript
          主站蜘蛛池模板: 南木林县| 汉源县| 赤水市| 英吉沙县| 辽宁省| 甘南县| 洛扎县| 河南省| 景洪市| 恭城| 当涂县| 云梦县| 鹤山市| 内江市| 梁平县| 安岳县| 许昌市| 内乡县| 吉安市| 平顺县| 措美县| 南阳市| 民和| 砚山县| 公安县| 北京市| 城口县| 辽阳市| 定边县| 福州市| 灵台县| 肇东市| 陕西省| 长治县| 宜阳县| 双峰县| 理塘县| 武山县| 区。| 太和县| 海阳市|