Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

jQuery conflict with userforms


Go to End


4 Posts   2936 Views

Avatar
s_a_m_y

Community Member, 31 Posts

9 March 2011 at 12:15am

Some threads indicate there is a general chance of jQuery-conflicts with userforms.

I am using jQuery jScrollPane for individual ScrollPanes on a project. Works perfectly on all extended Pages except the ones where I use UDF. On these nothing happens and I get thrown the Error:

Uncaught TypeError: Object #<an Object> has no method 'jScrollPane'

Others seem to also have troubles adding their own jQuery-Code to UDF-pages. I haven't found a proper solution though. I have included the script files in the Page.php:

Requirements::javascript("mysite/javascript/jquery-1.4.2.js");
Requirements::javascript("mysite/javascript/jquery-ui-1.8.custom.min.js");
Requirements::javascript("mysite/javascript/jquery.mousewheel.js");
Requirements::javascript("mysite/javascript/jquery.jscrollpane.js");
Requirements::javascript("mysite/javascript/mwheelIntent.js");
Requirements::javascript("mysite/javascript/bgss_script.js");

They all get loaded correctly, and, as said, work perfectly on all other pages. I appreciate any suggestion.
Thanks
Samy

Avatar
s_a_m_y

Community Member, 31 Posts

9 March 2011 at 2:12am

Ok, I found a working solution. This might help other beginners, too:

$.noConflict();
jQuery(document).ready(function($){
$(function()
{
$('#Content').jScrollPane({showArrows: true});
});
});

Avatar
Willr

Forum Moderator, 5523 Posts

9 March 2011 at 10:07pm

That solution seems quite verbose!

You normally just need to wrap your own code in a closure. I use UDF + scrollpane on a couple of my sites..

(function($) {
$(document).ready(function() {

// your code;
})
})(jQuery);

Avatar
s_a_m_y

Community Member, 31 Posts

10 March 2011 at 2:04am

Hi Willr,

thanks for your advise. Your code works well!

Samy