七段

          無(wú)論怎樣,請(qǐng)讓我先感謝一下國(guó)家。

          BlogJava 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
            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 人發(fā)表留言,猛擊->>這里<<-參與討論


          JavaEye推薦




          文章來(lái)源:http://sevenduan.javaeye.com/blog/507354
          posted on 2009-10-31 14:49 sevenduan 閱讀(409) 評(píng)論(0)  編輯  收藏 所屬分類: JavaScript
          主站蜘蛛池模板: 乐山市| 舞钢市| 堆龙德庆县| 泰和县| 安国市| 云梦县| 贡嘎县| 太谷县| 东阿县| 澄迈县| 峨山| 和硕县| 广西| 措勤县| 潮安县| 石棉县| 宁明县| 安阳市| 太仓市| 镇赉县| 华宁县| 竹溪县| 多伦县| 云阳县| 阿城市| 尖扎县| 胶南市| 刚察县| 常山县| 宕昌县| 海宁市| 汉源县| 衡水市| 新安县| 嵩明县| 江达县| 道真| 怀柔区| 永年县| 磴口县| 汾阳市|