2

Good day,

I'm trying to add a jquery UI datepicker to my Magento store. Everything works as it should outside MAgento, but when I add it to Magento nothing happens. Ive added the jquery file to the appropriate folder in magento js, and correctly added the file to the page.xml file. I've been playing around with the noconflict.js but so far no joy. My code is below. Please let me know if I am doing something incorrect or if there may be a step I skipped.

Thank you

$j(function() {
$j( "#datepicker" ).datepicker();
});
jQuery.noConflict();

2 Answers 2

3

It depends on your version of Magento. For later version, you should already have a jQuery bundled in Magento and a noConflict done for you (since magento is historically still using prototypeJs).

So if you are on one of the latest version, then you should just be ok with $j for jQuery, so this way.

$j(function() {
    $j( "#datepicker" ).datepicker();
});

Because Magento is doing

var $j = jQuery.noConflict();

for you in the file /js/lib/jquery/noconflict.js already

If not, then you will have to have the line var $j = jQuery.noConflict(); either in a file included just after your jQuery lib, or at the very last line of your jQuery lib.

One other possibility is to simply do

jQuery.noConflict();
jQuery(function() {
    jQuery( "#datepicker" ).datepicker();
});
Sign up to request clarification or add additional context in comments.

Comments

0

Thank you for the info. I ended up figuring it out. Perhaps adding jquery UI to the XML was needed. DERP

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.