Forum Moderators: open

Message Too Old, No Replies

Issue with the $

         

toplisek

10:30 pm on Dec 20, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It seems it is not the correct coded when I transform $ into jQuery.

Which code is actually correct when using jQuery.noConflict();
Code is validated and it works but need to add $ = jQuery; in the correct way.
$(function ()
{
var $sections = $('.form-section');
function navigateTo(index) {

$sections
.removeClass('current')
.eq(index)
.addClass('current');

$('.form-navigation .previous').toggle(index > 0);
var atTheEnd = index >= $sections.length - 1;
$('.form-navigation .next').toggle(!atTheEnd);
$('.form-navigation [type=submit]').toggle(atTheEnd);
}
function curIndex() {

return $sections.index($sections.filter('.current'));
}

$('.form-navigation .previous').click(function()
{
navigateTo(curIndex() - 1);
}
);

$('.form-navigation .next').click(function()
{
if ($('.demo-form').parsley().validate('block-' + curIndex()))
navigateTo(curIndex() + 1);
}
);

$sections.each(function(index, section)
{
$(section).find(':input').attr('data-parsley-group', 'block-' + index);
}
);
navigateTo(0);
}

);

Need help.

coopster

4:56 pm on Jan 3, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You just need to wrap it properly:

<script src="other_lib.js"></script>
<script src="jquery.js"></script>
<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
</script>


Resource:
[api.jquery.com...]