2

I am currently designing a website where I am using the jQuery ScrollTo plug-in, which uses the jQuery 1.6.2 library. As part of the website, I am required to create an Ajax contact form (I need to make sure it does not take the user to another page, as it's a vertically scrolling site in which all content is on one page). The only jQuery Ajax form I could find uses jQuery 1.3.2. I've done a little bit of reading around about the noConflict() mode, but being a bit of a beginner in Java/PHP, I'm really not sure of how to use it.

My current <head> code is as follows:

<script type="text/javascript" src="jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="form/js/jquery-1.3.2.js"></script>

<script type="text/javascript" src="jquery/jquery.scrollTo.js"></script>
<script type="text/javascript" src="form/js/js.js"></script>

The first two lines are calling on the two jQuery libraries, and the second ones are the specific codes for the scroll and the form.

I'm really unclear of how to use noConflict with these codes, can someone please help me? I know this question has been asked a lot of times before, but I'm just confused by it!

Please note that I call on my libraries within the page, but no JS is actually written WITHIN the homepage document, it's all in other files, eg: form/js/js.js.

Thanks a lot to anyone that can help me, very much appreciated.

Siva Charan
  • 17,940
  • 9
  • 60
  • 95
  • You couldn't find jQuery Ajax Form plug-ins that work in 1.6? Can't be, there must be a few at least... – Šime Vidas Oct 15 '11 at 11:41
  • 1
    This one - http://jquery.malsup.com/form/ - is compatible with 1.3.2 **and later**. (The last update was **one week ago**. [See here](https://github.com/malsup/form).) – Šime Vidas Oct 15 '11 at 11:42
  • also this is possible duplicate of [Can I use multiple versions of jQuery on the same page?](http://stackoverflow.com/questions/1566595) and [How do I run different versions of jQuery on the same page?](http://stackoverflow.com/questions/528241) – naveen Oct 15 '11 at 11:45
  • possible duplicate of [How do I run different versions of jQuery on the same page?](http://stackoverflow.com/questions/528241/how-do-i-run-different-versions-of-jquery-on-the-same-page) – Felix Kling Oct 15 '11 at 12:43
  • Also 1.6.x can easily ajax a form without the use of plugins – mplungjan Oct 15 '11 at 13:36

2 Answers2

0

try this:

var jq = jQuery.noConflict();

(function($) { 
  $(function() {
    // more code using $ as alias to jQuery
  });
})(jq );
Shlomi Komemi
  • 5,445
  • 3
  • 28
  • 41
  • You could also do `jq(function($) {...})`. – pimvdb Oct 15 '11 at 12:51
  • Thanks very much, do I need to enter this code inside of –  Oct 15 '11 at 13:01
0

I has solved my similar problem by using the below code.

HTML Code:

<div class="mycssclass">
<h2 >FAQs</h2>
<p >01. <a href="#06Answer">This is my first Question?</a>
</p>
</div>
----
----
<p><a name="01Answer"></a>
<br>This is my Answer.</p>

JQuery Code:

customfaq: function(){ 
$('.mycssclass p:eq(1)').click(function(){
var p = $(".mycssclass p:eq(1)");
var position = p.position();
$(document).scrollTo( {top:position.top,left:position.left}, 800 ); });}

For more details, Please look into http://api.jquery.com/scrollTop/ and http://api.jquery.com/category/offset/

Irshad A
  • 1
  • 1