您如何将站点从Prototype切换到jQuery [英] How would you go about for switching a site from Prototype to jQuery

查看:76
本文介绍了您如何将站点从Prototype切换到jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Prototype中编写了一个网站但想切换到jQuery。关于如何最好地进行切换的任何想法?

I have written a site in Prototype but want to switch to jQuery. Any ideas on how best make the switch?

推荐答案

就我个人而言,我喜欢分步进行,所以我先从使用开始两者都是这样的:

Personally, I like to take things in steps, so I would start by using both, like this:

jQuery.noConflict();

// Put all your code in your document ready area
jQuery(document).ready(function($){
  // Do jQuery stuff using $
  $("div").hide();
});

// Use Prototype with $(...), etc.
$('someid').hide();

这样你就不必一次转换所有旧代码,但可以开始使用jquery关于新东西,并在方便时迁移旧的Prototype代码。我不知道你的项目的大小,所以我不能说这是否适用于你,但是Spolsky有一篇很棒的文章关于大改写以及为什么它在你不应该做的事情,第1部分。非常值得一读!

That way you don't have to convert all your old code at once, but can start using jquery on new stuff, and migrate your old Prototype code when ever it's convenient. I don't know the size of your project, so I can't say whether or not this applies to you, but Spolsky had a great article about "The big rewrite" and why it's such a bad idea in Things you should never do, Part 1. It's well worth a read!

有关在原型中使用jquery的更多信息,请参阅在jquery文档中使用jQuery和其他库

For more on using jquery with Prototype, see Using jQuery with other libraries in the jquery docs.

这篇关于您如何将站点从Prototype切换到jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆