JavaScript - Conflict Using Jquery, Mootools, Prototype
Hello all
I have been trying in vain for many days to resolve a conflict between javascript libraries. I have read far and wide and still have failed to fix this problem, most likely because my programming skills are just about copy and pasting. My homepage uses jquery horizontal css menubar + a combined mootool and prototype accordian type sliding information box in the middle of the webpage. I find that the highlighter of the css menubar does not work when prototype.js is also loaded on the same page. I have read somewhere that $ should be replaced however I have tried every possible option and none works. I have jquery loading first as it is on my template, with this <script type='text/javascript' src='../Web/Templates/jquery-1.3.2.js'></script> <script type='text/javascript' src='js/example.js'></script> And my mootool and prototype loades further below like this <script type="text/javascript" src="scripts/intro/prototype.lite.js"></script> <script type="text/javascript" src="scripts/intro/moo.fx.js"></script> <script type="text/javascript" src="scripts/intro/moo.fx.pack.js"></script> <script type="text/javascript"> function init(){ var stretchers = document.getElementsByClassName('box'); var toggles = document.getElementsByClassName('tab'); var myAccordion = new fx.Accordion( toggles, stretchers, {opacity: false, height: true, duration: 600} ); //hash functions var found = false; toggles.each(function(h3, i){ var div = Element.find(h3, 'nextSibling'); if (window.location.href.indexOf(h3.title) > 0) { myAccordion.showThisHideOpen(div); found = true; } }); if (!found) myAccordion.showThisHideOpen(stretchers[0]); } </script> Could someone please offer me further assistance and enlighten me what other information you require to assist me further. I have attached the example.js inside example.zip file if someone could kindly edit it for myself. Looking forward to your assistance. Sincerely, Lex Similar TutorialsI'm currently trying to make a contact form using mootools FormCheck and mootools Form.Send in conjunction with each other. Each one will function correctly individually, but once I have all three: mootools.js (required by form.send) mootools-more.js (required by FormCheck) mootools-core.js (required by FormCheck) linked in my header, the form.send becomes dominant and my formcheck doesn't function at all. I'm specifically using form.send so that I can post a success (or failure) message without reloading the contact page. I'm using FormCheck - obviously to check that required fields are filled out. I have stripped the form from the website itself here. and here are the two pieces of code I'm using: FormCheck Code: <script type="text/javascript"> window.addEvent('domready', function(){ new FormCheck('myform'); }); </script> Form.Send Code: <script type="text/javascript"> var fx = { 'loading': new Fx.Style( 'loading', 'opacity',{ duration: 400 } ), 'success': new Fx.Style( 'success', 'opacity',{ duration: 400 } ), 'fail': new Fx.Style( 'fail', 'opacity',{ duration: 400 } ) }; var showHide = function( el ){ fx.loading.set(0); (fx[ el ]).start(0,1); (function(){ (fx[ el ]).start(1,0); }).delay( 20000 ); } $('submit').addEvent( 'click', function(evt){ new Event(evt).stop(); $('myform').send({ onRequest: function(){ fx.loading.start( 1,0 ); }, onSuccess: function(){ showHide( 'success' ); }, onFailu function(){ showHide( 'fail' ); } }); } ); </script> I have no idea what I'm doing with javascript, but I imagine I need a line that tells the script if FormCheck is successful, run Form.Send ? Anything would help at this point. --Eric im currently using a prototype add on for one of my sites and id like to convert it to mootools... problem is, i dont know the first thing about prototype! i stumbled upon this before i learned any javascript and ive gotten to know mootools and like using it... heres the code, let me know if anyone can help! Code: /** * @author Bruno Bornsztein <bruno@missingmethod.com> * @copyright 2007 Curbly LLC * @package Glider * @license MIT * @url http://www.missingmethod.com/projects/glider/ * @version 0.0.3 * @dependencies prototype.js 1.5.1+, effects.js */ /* Thanks to Andrew Dupont for refactoring help and code cleanup - http://andrewdupont.net/ */ Glider = Class.create(); Object.extend(Object.extend(Glider.prototype, Abstract.prototype), { initialize: function(wrapper, options){ this.scrolling = false; this.wrapper = $(wrapper); this.scroller = this.wrapper.down('div.scroller'); this.sections = this.wrapper.getElementsBySelector('div.section'); this.options = Object.extend({ duration: 1.0, frequency: 3 }, options || {}); this.sections.each( function(section, index) { section._index = index; }); this.events = { click: this.click.bind(this) }; this.addObservers(); if(this.options.initialSection) this.moveTo(this.options.initialSection, this.scroller, { duration:this.options.duration }); // initialSection should be the id of the section you want to show up on load if(this.options.autoGlide) this.start(); }, addObservers: function() { var controls = this.wrapper.getElementsBySelector('div.controls a'); controls.invoke('observe', 'click', this.events.click); }, click: function(event) { this.stop(); var element = Event.findElement(event, 'a'); if (this.scrolling) this.scrolling.cancel(); this.moveTo(element.href.split("#")[1], this.scroller, { duration:this.options.duration }); Event.stop(event); }, moveTo: function(element, container, options){ this.current = $(element); Position.prepare(); var containerOffset = Position.cumulativeOffset(container), elementOffset = Position.cumulativeOffset($(element)); this.scrolling = new Effect.SmoothScroll(container, {duration:options.duration, x:(elementOffset[0]-containerOffset[0]), y:(elementOffset[1]-containerOffset[1])}); return false; }, next: function(){ if (this.current) { var currentIndex = this.current._index; var nextIndex = (this.sections.length - 1 == currentIndex) ? 0 : currentIndex + 1; } else var nextIndex = 1; this.moveTo(this.sections[nextIndex], this.scroller, { duration: this.options.duration }); }, previous: function(){ if (this.current) { var currentIndex = this.current._index; var prevIndex = (currentIndex == 0) ? this.sections.length - 1 : currentIndex - 1; } else var prevIndex = this.sections.length - 1; this.moveTo(this.sections[prevIndex], this.scroller, { duration: this.options.duration }); }, stop: function() { clearTimeout(this.timer); }, start: function() { this.periodicallyUpdate(); }, periodicallyUpdate: function() { if (this.timer != null) { clearTimeout(this.timer); this.next(); } this.timer = setTimeout(this.periodicallyUpdate.bind(this), this.options.frequency*1000); } }); Effect.SmoothScroll = Class.create(); Object.extend(Object.extend(Effect.SmoothScroll.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); var options = Object.extend({ x: 0, y: 0, mode: 'absolute' } , arguments[1] || {} ); this.start(options); }, setup: function() { if (this.options.continuous && !this.element._ext ) { this.element.cleanWhitespace(); this.element._ext=true; this.element.appendChild(this.element.firstChild); } this.originalLeft=this.element.scrollLeft; this.originalTop=this.element.scrollTop; if(this.options.mode == 'absolute') { this.options.x -= this.originalLeft; this.options.y -= this.originalTop; } }, update: function(position) { this.element.scrollLeft = this.options.x * position + this.originalLeft; this.element.scrollTop = this.options.y * position + this.originalTop; } }); Hello, I have a problem with my code which only appears in ie (more specifically on ie8, I haven't tested it on any other versions yet). I have absolutely no problems with firefox (v4) or Chrome (v10). I am trying to use the standalone version of the RokBox plugin (http://www.rockettheme.com/extensions-joomla/rokbox), which uses mootools-release-1.11.js. The use of rokbox in my application is necessary for me in order to easily display some linked files with a fancy pop-up box and more importantly to use the "gallery" property so that my links can be grouped together and shown in order by just clicking some "next" button... To explain this (I 'll try to be as thorough as possible so that you get what happens): 1)I am using an index.php file which is as you can guess of course the "index". 2)I am calling some functions to compose a query for my database. 3)I am using AJAX to send those queries in another file called values.php. 4)This file takes the data from my database and echoes them. 5)The echoed values are returned and echoed in index.php as options (dropdown list). 6)When the user selects a value on a field some new queries are composed and AJAX is called again but this time it sends data to another file called results.php which echoes back the found matches to a specified div on index.php. (And also calls values.php again to pass new queries). 7) The data returned from the results contain a link to another file called details.php. 8)I am using RokBox to make these links open in a fancy pop-up box with arrows that point to the next or previous link based on the gallery that was generated by RokBox. Now here's some parts of my code: index.php header section (attention:some of this code is commented): [HTML] <script type="text/javascript" src="../rokbox/mootools-release-1.11.js"></script> <!--<script type="text/javascript" src="../rokbox/mootools-core-1.3.1-full-compat.js"></script>--> <!--<script type="text/javascript" src="../rokbox/mootools-1.2.5-core-nc.js"></script>--> <script type="text/javascript" src="../rokbox/rokbox.js"></script> <link href="../rokbox/themes/mynxx/rokbox-style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../rokbox/themes/mynxx/rokbox-config.js"></script> <script type="text/javascript" src="myscript.js"></script> <script type="text/javascript" src="allfields.js"></script> [/HTML]myscript.js (part of it): Code: function AJAX(i,query){ /* Establish AJAX connection */ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari try{ xmlhttp[i]=new XMLHttpRequest(); }catch(err){ alert("ERROR IN AJAX["+i+"]: "+err)} } else {// code for IE6, IE5 xmlhttp[i]=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp[i].onreadystatechange=function() //line 21 {//alert("check"); if (xmlhttp[i].readyState==4 && xmlhttp[i].status==200) { document.getElementById("opt"+i).innerHTML=xmlhttp[i].responseText; if(i==-1) mybox(); //I'm re-calling RokBox here so that it can recognize the new items } } /* Send data to php file */ // alert("Field: "+obj[i].field+" \n Query: "+query); if(i!=-1){ xmlhttp[i].open("POST","values.php",true); xmlhttp[i].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp[i].send('query='+query+'&field='+obj[i].field+'&i='+i); }else{ xmlhttp[i].open("POST","../results.php",true); xmlhttp[i].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp[i].send('query='+query); } } Now the problem: On every first run of this webpage using ie I get the following error generated by the try-catch commands: Code: ERROR IN AJAX[0]: TypeError: Object doesn't support this property or method Then everything freezes... IE itself throws me the following error: Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C) Timestamp: Sat, 2 Apr 2011 12:34:07 UTC Message: 'xmlhttp[...]' is null or not an object Line: 21 Char: 4 Code: 0 URI: http://.............../advanced/myscript.js Line 21 is marked on the script code with comments. These errors do not reoccur when the page is reloaded (and as I already said it only happens with ie). So, by this error (and after some debugging) I get that for some reason the AJAX methods are not called as ought to be when I use the tag: [HTML]<script type="text/javascript" src="../rokbox/mootools-release-1.11.js"></script>[/HTML]on my index's head section. So... AJAX cannot work with using mootools? After some research, I found that mootools which uses the $ sign to start it's operations, conflicts with other libraries (such as jQuery) using the same sign ($) for their own reasons. Now I found that the way to fix this is by using jQuery.noconflict() after your jQuery script. There's only one little thing: I DON'T use jQuery, so where is the conflict? I also tried updating mootools to a newer release (as you can see from the comments in head section) but I realized that RokBox can't work with other versions. I am pretty desperate with this, and I would really appreciate any solutions you can offer with your experience or any suggestions you think would help. You can check the issue your self by visiting my link: http://e-tech.ath.cx/ares/project%20...nced/index.php Hey All - I asked this a few days ago.. what I came up with works just fine, but I feel it doesn't take advantage of "classes". If you think I could make this better by turning it into a class or using some other notation, that would be great. Keep in mind, ALL this does is rewrite a pagination.... for a search return in a lightbox. I have this function called in the return function... Code: var srcpagParams = $H(); function buildPagi(param, currdsplyNum){ var temDsply = new Template('<strong>[#{total_display}<span id="count">#{prevImg} #{links} #{nextImg}</span>'), crnt_link = srcpagParams.set('crnt_link', param), // the page we want to see dsplyNum = srcpagParams.get('paginateNum'), // what is the number of returns per page ttl_lnks = Math.ceil( srcpagParams.get('numFound') / srcpagParams.get('paginateNum')), // total pages data_template = new Hash(); data_template.set('total_display',srcpagParams.get('numFound')); bldImg = function() { var prvB = '<a href="#content" id="pagiPrev" onclick="firesrc(this)">Prev<img src="blank.gif" /></a>'; var nxtB = '<a href="#content" id="pagiNext" onclick="firesrc(this)">Next<img src="blank.gif" /></a>'; data_template.set('prvImg',(crnt_link > 1) ? prvB : ""); data_template.set('nxtImg',(crnt_link < ttl_lnks) ? nxtB : ""); } bldLk = function(){ var holder = ""; if(ttl_lnks > 1){ var linkStr = new Template(' <a href="#content" onclick="firesrc(#{pos});"> Go to page #{pos}</a> '); $R(1,ttl_lnks).each(function(n) { var posit = {pos : n} holder += (crnt_link == n) ? " " + n + " " : linkStr.evaluate(posit); }); data_template.set('links',linkholder); } } bldRng = function(){ var currPaneRg = (dsplyNum * crnt_link) - (dsplyNum - currdsplyNum); data_template.set('range',((crnt_link - 1) * (dsplyNum) + 1 ) + " - " + currPaneRg); $('pages').update(temDsply.evaluate(data_template)).show(); } firesrc = function(cl){ var pagiPane = (typeof cl === "number") ? cl : (cl.id == "pagiNext") ? crnt_link + 1 : crnt_link - 1; var start = crnt_link * srcpagParams.get('paginateNum'); Alertsrc( $F('query') ,(pagiPane)) // pass the query to the json to return the current search request } bldImg(); buildLnk(); bldRng(); }; Since some of the data declared at the top changes depending on the return, I didn't know if I could "initialize" it in a class. But could I turn this into a class and if so - what I just use: var buildPagi = create.Class({ initialize: object.extend({ }) }) Call the function when we are passed some data: Code: buildPagi(somevalue, somevalue2) ** NOTE: I use the libraries prototype and jquery.. so use Create.Class and new Template are within the libraries... etc.. so, is there a more eloquent, or robust way to write what I did above? Hello guys, I need some help. I am very noob in Jquery and Mootools .. and they were getting conflicted on one page. I tried every tutorial available online but I couldn't get my jquery slideshow and mootools menu to work together. Not even by the jquery no conflict command. Code: window.addEvent('domready', function(){ //-vertical var mySlide = new Fx.Slide('v.menu-4'); mySlide.hide(); $('toggle-4').addEvent('click', function(e){ e = new Event(e); mySlide.toggle(); e.stop(); }); }); This script is for vertical menus and written for mootools 1.11 Can anybody help me out? Hi guys, I'm relatively new to coding, so apologies if this is something really trivial or even uneccessarily long. I'm currently running a mootools and a jquery script on the same page (http://tamwardsings.squarespace.com/media). Jquery = Jplayer audio player mootools = video light box Initially the jquery script wasn't working but I resolved that with var $j = jQuery.noConflict(); Now, while both scripts run in Chrome and Safari Browsers, firefox will not initiate either script. Clicking an image with a link to the video lightbox instead sends you directly to the anchored link, and the audio player, fails to play. Videobox script: Code: var Videobox = { init: function (options) { // init default options this.options = Object.extend({ resizeDuration: 400, // Duration of height and width resizing (ms) initialWidth: 250, // Initial width of the box (px) initialHeight: 250, // Initial height of the box (px) defaultWidth: 425, // Default width of the box (px) defaultHeight: 350, // Default height of the box (px) animateCaption: true, // Enable/Disable caption animation flvplayer: 'storage/js/flvplayer.swf' }, options || {}); this.anchors = []; $A($$('a')).each(function(el){ if(el.rel && el.href && el.rel.test('^vidbox', 'i')) { el.addEvent('click', function (e) { e = new Event(e); e.stop(); this.click(el); }.bind(this)); this.anchors.push(el); } }, this); this.overlay = new Element('div').setProperty('id', 'lbOverlay').injectInside(document.body); this.center = new Element('div').setProperty('id', 'lbCenter').setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none'}).injectInside(document.body); this.bottomContainer = new Element('div').setProperty('id', 'lbBottomContainer').setStyle('display', 'none').injectInside(document.body); this.bottom = new Element('div').setProperty('id', 'lbBottom').injectInside(this.bottomContainer); new Element('a').setProperties({id: 'lbCloseLink', href: '#'}).injectInside(this.bottom).onclick = this.overlay.onclick = this.close.bind(this); this.caption = new Element('div').setProperty('id', 'lbCaption').injectInside(this.bottom); this.number = new Element('div').setProperty('id', 'lbNumber').injectInside(this.bottom); new Element('div').setStyle('clear', 'both').injectInside(this.bottom); var nextEffect = this.nextEffect.bind(this); this.fx = { overlay: this.overlay.effect('opacity', {duration: 500}).hide(), center: this.center.effects({duration: 500, transition: Fx.Transitions.sineInOut, onComplete: nextEffect}), bottom: this.bottom.effect('margin-top', {duration: 400}) }; }, click: function(link) { return this.open (link.href, link.title, link.rel); }, open: function(sLinkHref, sLinkTitle, sLinkRel) { this.href = sLinkHref; this.title = sLinkTitle; this.rel = sLinkRel; this.position(); this.setup(); this.video(this.href); this.top = Window.getScrollTop() + (Window.getHeight() / 15); this.center.setStyles({top: this.top+'px', display: ''}); this.fx.overlay.start(0.8); this.step = 1; this.center.setStyle('background','#fff url("/storage/loading.gif) no-repeat center'); this.caption.innerHTML = this.title; this.fx.center.start({'height': [this.options.contentsHeight]}); }, setup: function(){ var aDim = this.rel.match(/[0-9]+/g); this.options.contentsWidth = (aDim && (aDim[0] > 0)) ? aDim[0] : this.options.defaultWidth; this.options.contentsHeight = (aDim && (aDim[1] > 0)) ? aDim[1] : this.options.defaultHeight; }, position: function(){ this.overlay.setStyles({'top': window.getScrollTop()+'px', 'height': window.getHeight()+'px'}); }, video: function(sLinkHref){ if (sLinkHref.match(/youtube\.com\/watch/i)) { this.flash = true; var hRef = sLinkHref; var videoId = hRef.split('='); this.videoID = videoId[1]; this.so = new SWFObject("http://www.youtube.com/v/"+this.videoID, "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0"); this.so.addParam("wmode", "transparent"); } else if (sLinkHref.match(/metacafe\.com\/watch/i)) { this.flash = true; var hRef = sLinkHref; var videoId = hRef.split('/'); this.videoID = videoId[4]; this.so = new SWFObject("http://www.metacafe.com/fplayer/"+this.videoID+"/.swf", "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0"); this.so.addParam("wmode", "transparent"); } else if (sLinkHref.match(/google\.com\/videoplay/i)) { this.flash = true; var hRef = sLinkHref; var videoId = hRef.split('='); this.videoID = videoId[1]; this.so = new SWFObject("http://video.google.com/googleplayer.swf?docId="+this.videoID+"&hl=en", "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0"); this.so.addParam("wmode", "transparent"); } else if (sLinkHref.match(/ifilm\.com\/video/i)) { this.flash = true; var hRef = sLinkHref; var videoId = hRef.split('video/'); this.videoID = videoId[1]; this.so = new SWFObject("http://www.ifilm.com/efp", "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0", "#000"); this.so.addVariable("flvbaseclip", this.videoID+"&"); this.so.addParam("wmode", "transparent"); } else if (sLinkHref.match(/\.mov/i)) { this.flash = false; if (navigator.plugins && navigator.plugins.length) { this.other ='<object id="qtboxMovie" type="video/quicktime" codebase="http://www.apple.com/qtactivex/qtplugin.cab" data="'+sLinkHref+'" width="'+this.options.contentsWidth+'" height="'+this.options.contentsHeight+'"><param name="src" value="'+sLinkHref+'" /><param name="scale" value="aspect" /><param name="controller" value="true" /><param name="autoplay" value="true" /><param name="bgcolor" value="#000000" /><param name="enablejavascript" value="true" /></object>'; } else { this.other = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+this.options.contentsWidth+'" height="'+this.options.contentsHeight+'" id="qtboxMovie"><param name="src" value="'+sLinkHref+'" /><param name="scale" value="aspect" /><param name="controller" value="true" /><param name="autoplay" value="true" /><param name="bgcolor" value="#000000" /><param name="enablejavascript" value="true" /></object>'; } } else if (sLinkHref.match(/\.wmv/i) || sLinkHref.match(/\.asx/i)) { this.flash = false; this.other = '<object NAME="Player" WIDTH="'+this.options.contentsWidth+'" HEIGHT="'+this.options.contentsHeight+'" align="left" hspace="0" type="application/x-oleobject" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"><param NAME="URL" VALUE="'+sLinkHref+'"><param><param NAME="AUTOSTART" VALUE="false"></param><param name="showControls" value="true"></param><embed WIDTH="'+this.options.contentsWidth+'" HEIGHT="'+this.options.contentsHeight+'" align="left" hspace="0" SRC="'+sLinkHref+'" TYPE="application/x-oleobject" AUTOSTART="false"></embed></object>' } else if (sLinkHref.match(/\.flv/i)) { this.flash = true; this.so = new SWFObject(this.options.flvplayer+"?file="+sLinkHref, "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0", "#000"); } else { this.flash = true; this.videoID = sLinkHref; this.so = new SWFObject(this.videoID, "flvvideo", this.options.contentsWidth, this.options.contentsHeight, "0"); } }, nextEffect: function(){ switch (this.step++){ case 1: this.fx.center.start({'width': [this.options.contentsWidth], 'marginLeft': [this.options.contentsWidth/-2]}); break; this.step++; case 2: this.center.setStyle('background','#fff'); this.flash ? this.so.write(this.center) : this.center.setHTML(this.other) ; this.bottomContainer.setStyles({top: (this.top + this.center.clientHeight)+'px', height: '0px', marginLeft: this.center.style.marginLeft, width: this.options.contentsWidth+'px',display: ''}); if (this.options.animateCaption){ this.fx.bottom.set(-this.bottom.offsetHeight); this.bottomContainer.style.height = ''; this.fx.bottom.start(0); break; } this.bottomContainer.style.height = ''; this.step++; } }, close: function(){ this.fx.overlay.start(0); this.center.style.display = this.bottomContainer.style.display = 'none'; this.center.innerHTML = ''; return false; } }; window.addEvent('domready', Videobox.init.bind(Videobox)); HTML for videobox: Code: <script src="/storage/js/mootools.js"></script> <script src="/storage/js/swfobject.js"></script> <script src="/storage/js/videobox.js"></script> <link href="/storage/js/videobox.css" media="screen" rel="stylesheet" type="text/css" /> <div id="vid1"><a title="caption" rel="vidbox" href="http://www.youtube.com/watch?v=3xpM1MPMjBc"><img src="/storage/vid1.jpg" alt="" /></a></div> <div id="vid2"><a title="caption" rel="vidbox" href="http://www.youtube.com/watch?v=3xpM1MPMjBc"><img src="/storage/vid2.jpg" alt="" /></a></div> <div id="vid2"><a title="caption" rel="vidbox" href="http://www.youtube.com/watch?v=3xpM1MPMjBc"><img src="/storage/vid3.jpg" alt="" /></a></div> Jplayer javascript: Code: //<![CDATA[ var $j = jQuery.noConflict(); $j(document).ready(function(){ var Playlist = function(instance, playlist, options) { var self = this; this.instance = instance; // String: To associate specific HTML with this playlist this.playlist = playlist; // Array of Objects: The playlist this.options = options; // Object: The jPlayer constructor options for this playlist this.current = 0; this.cssId = { jPlayer: "jquery_jplayer_", interface: "jp_interface_", playlist: "jp_playlist_" }; this.cssSelector = {}; $j.each(this.cssId, function(entity, id) { self.cssSelector[entity] = "#" + id + self.instance; }); if(!this.options.cssSelectorAncestor) { this.options.cssSelectorAncestor = this.cssSelector.interface; } $j(this.cssSelector.jPlayer).jPlayer(this.options); $j(this.cssSelector.interface + " .jp-previous").click(function() { self.playlistPrev(); $j(this).blur(); return false; }); $j(this.cssSelector.interface + " .jp-next").click(function() { self.playlistNext(); $j(this).blur(); return false; }); }; Playlist.prototype = { displayPlaylist: function() { var self = this; $j(this.cssSelector.playlist + " ul").empty(); for (i=0; i < this.playlist.length; i++) { var listItem = (i === this.playlist.length-1) ? "<li class='jp-playlist-last'>" : "<li>"; listItem += "<a href='#' id='" + this.cssId.playlist + this.instance + "_item_" + i +"' tabindex='1'>"+ this.playlist[i].name +"</a>"; // Create links to free media if(this.playlist[i].free) { var first = true; listItem += "<div class='jp-free-media'>("; $j.each(this.playlist[i], function(property,value) { if($j.jPlayer.prototype.format[property]) { // Check property is a media format. if(first) { first = false; } else { listItem += " | "; } listItem += "<a id='" + self.cssId.playlist + self.instance + "_item_" + i + "_" + property + "' href='" + value + "' tabindex='1'>" + property + "</a>"; } }); listItem += ")</span>"; } listItem += "</li>"; // Associate playlist items with their media $j(this.cssSelector.playlist + " ul").append(listItem); $j(this.cssSelector.playlist + "_item_" + i).data("index", i).click(function() { var index = $j(this).data("index"); if(self.current !== index) { self.playlistChange(index); } else { $j(self.cssSelector.jPlayer).jPlayer("play"); } $j(this).blur(); return false; }); // Disable free media links to force access via right click if(this.playlist[i].free) { $j.each(this.playlist[i], function(property,value) { if($j.jPlayer.prototype.format[property]) { // Check property is a media format. $j(self.cssSelector.playlist + "_item_" + i + "_" + property).data("index", i).click(function() { var index = $j(this).data("index"); $j(self.cssSelector.playlist + "_item_" + index).click(); $j(this).blur(); return false; }); } }); } } }, playlistInit: function(autoplay) { if(autoplay) { this.playlistChange(this.current); } else { this.playlistConfig(this.current); } }, playlistConfig: function(index) { $j(this.cssSelector.playlist + "_item_" + this.current).removeClass("jp-playlist-current").parent().removeClass("jp-playlist-current"); $j(this.cssSelector.playlist + "_item_" + index).addClass("jp-playlist-current").parent().addClass("jp-playlist-current"); this.current = index; $j(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]); }, playlistChange: function(index) { this.playlistConfig(index); $j(this.cssSelector.jPlayer).jPlayer("play"); }, playlistNext: function() { var index = (this.current + 1 < this.playlist.length) ? this.current + 1 : 0; this.playlistChange(index); }, playlistPrev: function() { var index = (this.current - 1 >= 0) ? this.current - 1 : this.playlist.length - 1; this.playlistChange(index); } }; var audioPlaylist = new Playlist("1", [ { name:"Tempered Song", mp3:"http://www.jplayer.org/audio/mp3/Miaow-01-Tempered-song.mp3" }, { name:"Hidden", mp3:"http://tamtam123.squarespace.com/storage/images/avenged_unholyc.mp3" } ], { ready: function() { audioPlaylist.displayPlaylist(); audioPlaylist.playlistInit(false); // Parameter is a boolean for autoplay. }, ended: function() { audioPlaylist.playlistNext(); }, play: function() { $j(this).jPlayer("pauseOthers"); }, swfPath: "storage/js", supplied: "mp3" }); $j("#jplayer_inspector_1").jPlayerInspector({jPlayer:$j("#jquery_jplayer_1")}); $j("#jplayer_inspector_2").jPlayerInspector({jPlayer:$j("#jquery_jplayer_2")}); }); //]]> Any help on this matter would be greatly appreciated, Josh hi guys! i was building a website using two jquery codes . first one for the slideshow banner and the other one for the menu but only one of them works, i've search on the web and i fouond something called jquery no conflict() is this good? this is the code inside de <head> tags Code: <!-- JavaScripts--> <script type="text/javascript"> jQuery.noConflict(); </script> /*This is the menu's*/ <script type='text/javascript' src="jquery-1.2.6.min.js"></script> <script type='text/javascript' src="kwicks.js"></script> <script type='text/javascript' src="custom.js"></script> /*Here starts the sideshow*/ <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/s3Slider.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#slider').s3Slider({ timeOut: 3000 }); }); </script> </head> Hi All, I am simply trying to get 2 booking systems working on the 1 page but it seems that they have a conflict, they both access the exact sames files but whatever one is at the top get priority and works and the 2nd one below doesn't. See he http://www.albergodelsenato.it/test2.php How can I fix this? Please help ASAP. Thanks I have read that if i have to use jquery with other libraries then i have to use jquery in no conflict mode. I understand that and and it works. i use Code: $j = jquery.noconflict() so that $ of jquery does not mix with $ of other libraries Now my question is that i use any jquery plugin , and i include that JS file Code: e,g plugin.jquery.js I am not sure whether i am correct or not i think that plugin is coded by using $ sign not the $j and i think it will conflict with other libraries. So it means i have to chnage the plugin code as well or there is no need to change plugin Can someone correct me if i am wrong Hi all I have a page on a website I am creating that has both a lightbox rel link and a quick calculator to work out a size of a product. Here are the links to the java files I am using: <link rel="stylesheet" href="css/style.css" type="text/css" media="all" /> <link rel="stylesheet" href="css/jquery.lightbox.css" type="text/css" media="screen" /> <script type="text/javascript" src="scripts/jquery.js"></script> <script type="text/javascript" src="scripts/jquery.lightbox.js"></script> <script type="text/javascript" src="scripts/swfobject.js"></script> <script type="text/javascript" src="scripts/sandstone.js"></script> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> <script src="scripts/prototype.js" type="text/javascript"></script> <script src="scripts/scriptaculous.js?load=effects,builder" type="text/javascript"></script> <script src="scripts/lightbox.js" type="text/javascript"></script> Here is the actual lightbox link: <a href="testimage.jpg" rel="lightbox" ><img src="testimage.jpg" > And finally the calculator: <form method="post" action=""> <table width="220" border="0" cellpadding="2" cellspacing="0"> <tr align="left"><td width="87" height="30" class="meter-calc-text">Width (m)</td> <td width="117" height="30" align="left"> <input name="width" type="text" id="calc-width" size="6" /></td> </tr> <tr align="left"><td height="30" class="meter-calc-text">Length (m)</td> <td height="30" align="left"><input name="length" type="text" id="calc-length" size="6" /></td> </tr> <tr align="left"><td height="40" colspan="2"> <select name="packcontents" class="meter-calc-dropdown" id="calc-packcontents" onchange="updateProduct(this.options[this.selectedIndex].id)" style="width:140px;"> <option value="0" selected class="meter-calc-text">Product Select</option> <option value="1" selected class="meter-calc-text">1</option> <option value="2" selected class="meter-calc-text">2</option> </select> <input type="button" name="go" value="Go" id="calc-trigger" class="calc-go" /> </td> </tr> <tr> </tr> </table> <table width="220" border="0" cellpadding="2" cellspacing="0"> <tr> <td width="83" height="30" class="meter-calc-text">You Requi </td> <td width="121" height="30" align="left" class="product-cell-info-table-text"> <input name="meters" type="text" class="small" id="calc-meters" value="" size="5" /> <span class="meter-calc-text">m2</span> </td> </tr> <tr> <td height="30" class="meter-calc-text"> </td> <td height="30" align="left" class="product-cell-info-table-text"> <input name="packs" type="text" class="small" id="calc-packs" value="" size="5" /> <span class="meter-calc-text">Packs</span> </td> </tr> </table> <input type="hidden" name="productid" id="productid" value=""> <div id="addit" style="display:none"> <a name="addit" class="meter-calc-text" onclick="location.href='basket.php?action=add&id='+$('#productid').val()+'&quantity='+$('#calc-packs').val()+'&return=http://www.cq-designs.co.uk/clientarea/sandstonecentre/clientarea/sandstonecentre/product.php?category=2&type=&colour=1'">Add To Cart</a> </div> </form> The problem I am having is that they both don't work together. If I comment out the lightbox javascript the calcukator works but not the lightbox and Vice Versa! Please help Thanks Pete The following code is needed for the prettyphoto javascript popup. It works fine in Firefox and Safari, but not in any version of IE. Can anyone suggest why? <script> jQuery.noConflict(); $(document).ready(function(){ jQuery("a[rel^='prettyPhoto']").prettyPhoto(); }); </script> I currently have to run jQuery.noConflict(); so my other scripts work correctly, examples: Code: prototype.js validation.js And i have this Code: $( document ).ready( function() { $( window ).scroll( function( e ) { if( $( window ).scrollTop() > 160 ) { $( '.navigation' ).addClass( 'fixed' ); } else { $( '.navigation' ).removeClass( 'fixed' ); } } ); } ); witch works when i take jQuery.noConflict(); out, but with it in it dont work and thats my main feature is there anyway round it, thanks. Please see URL: http://www.freedommd.com/Freedom10/index.shtml 1. On the navbar, click on "Demos > EMR Features" (using jQuery for the navbar) 2. On the "FreeDOM EMR" page, in addition to the jQuery navbar, I am using Lightbox to display images (click on the "dashboard" thumbnail). There is a conflict of some sort here between scripts. Code: <!--jquery menu code directly below--> <script type="text/javascript" language="javascript" src="js/jquery.js"></script> <script type="text/javascript" language="javascript" src="js/navmenus.js"></script> <!--end jquery nav--> <!--Lightbox code directly below--> <script type="text/javascript" src="js-lightbox/prototype.js"></script> <script type="text/javascript" src="js-lightbox/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js-lightbox/lightbox.js"></script> <!--end Lightbox --> As is, on this page, my Lightbox code works fine, but my navbar will not expand the sub menus. If I remove the Lightbox code, then the navbar works fine. I'd really like for them both to work. : ) I tried putting the .js in different directories, separating the Lightbox code from the jQuery code but that didn't help. All .js files are attached. Much appreciated if someone can tell me what I need to do. Thanks, John Hey guys I should preface this by saying that this is not for my own site, or my own code; a friend has gone on holiday and needed this project fixing while he was away. Unfortunately my experience with jQuery is almost nil and everything was coded by someone else, so I'm really tearing my hair out. This is a Wordpress installation running Thematic with two child themes, one of which uses Ajax calls to grab page content. The issue is that the Ajaxified calls stop the swfObject content from being loaded. Compa http://dev.segolondon.com/wp292/media/ <- Flash content loads versus: http://dev.segolondon.com/wp292/#wp292/media/ If you take a look at the code of the two pages, you'll see there are no swfobject.embedSWF() calls on the Ajaxified page. It seems as though the jQuery calls are pre-empting the JS/Flash detection, so the swfObject code is never even written to the page. The actual custom, handwritten code (i.e. not from a library or a plugin) on this site is minimal, so I'm grasping at straws to fix this. I read somewhere about using a script block like this: Code: <script> $(document).ready( function() { // Make the swfObject call } ); </script> But I'm not really sure where to put it since there are so many plugins used, all with slightly different embed methods. Any help would be very gratefully received! hi guys i really dont understand where i am going wrong.I've read countless articles including http://blog.nemikor.com/2009/10/03/u...ons-of-jquery/ but still having trouble with multiple versions of jquery not working. either the jquery slideshow doesnt work or the jquery ie select width fix doesnt work! rrghhh Code: <head> <link href="/css/styles.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/ie6pngfix/iepngfix_tilebg.js"></script><!-- ie6 png fix --> <script type="text/javascript" src="/js/ddlevelsmenu.js"></script><!-- drop down menu js --> <script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script><!-- slideshow jquery file 1 --> <script type="text/javascript" src="/js/slides.min.jquery.js"></script><!-- slideshow jquery file 2 --> <!-- slideshow jquery controls --> <script type="text/javascript"> jQuery(function () { // Set starting slide to 1 var startSlide = 1; // Get slide number if it exists if (window.location.hash) { startSlide = window.location.hash.replace('#', ''); } // Initialize Slides jQuery('#slides').slides({ preload: true, preloadImage: 'img/loading.gif', generatePagination: true, play: 5000, pause: 2500, slideSpeed: 1200, hoverPause: true, // Get the starting slide start: startSlide, animationComplete: function (current) { // Set the slide number as a hash // window.location.hash = '#' + current; } }); }); </script> <script type="text/javascript"> var jQuery_1_4_4 = $.noConflict(true); </script> <script type="text/javascript" src="/js/prototype.js"></script><!-- lightbox aka image viewer js file 1 --> <script type="text/javascript" src="/js/scriptaculous.js?load=effects,builder"></script><!-- lightbox aka image viewer js file 2 --> <script type="text/javascript" src="/js/lightbox.js"></script><!-- lightbox aka image viewer js file 3 --> <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function(jQuery) { </script> <script type="text/javascript" src="/js/test/jquery.1-4-2.min.js"></script> <script type="text/javascript" src="/js/test/jquery.ie-select-width.js"></script> <!--[if lte ie 6]> <script type="text/javascript" src="/js/test/jquery.bgiframe.js"></script> <![endif]--> <script type="text/javascript"> $(function () { // Set the width via the plugin. $('select#fixed-select-no-css').ieSelectWidth ({ width : 200, containerClassName : 'select-container', overlayClassName : 'select-overlay' }); // Set the width via CSS. $('select#fixed-select-css').ieSelectWidth ({ containerClassName : 'select-container', overlayClassName : 'select-overlay' }); // Borders and padding etc for Internet Explorer 6/7. $('select#select-styleable').ieSelectWidth ({ containerClassName : 'select-container', overlayClassName : 'select-overlay' }); }); </script> <script type="text/javascript"> var jQuery_1_4_2 = $.noConflict(true); </script> <!-- Share this button script --> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'c0b04a1e-f627-42e8-b040-cbfb63bd9b1c'});</script> <script type="text/javascript" src="/js/showtab.js"></script> </head> I've tried re ordering the scripts around but still no joy? either the slideshow works or the ie select width fix doesnt but not both at the same time? please advise Omar. Hi, I am trying to make the below jquery code to work, and the second click event does nothing. I understand this probably relates to the document ready section, that I am calling my form in the first click, but I am not sure the way around this. I have seen mention of using unbind, but I am not sure if it would apply in my case? My code is: Code: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function (){ $('#submitmessage').click(function(){ $('#messageboard').load('getloadCompose.php', function (){ $.ajax{(url:'getloadMessageBoard.php', sucess:function (result){ $("txtHint").html(result){ $('#submitFirst, #submitSecond').click(function(){ var btn = $(this).attr('id'); if(btn == 'submitFirst){ file = 'insertFirst.php'; Msg = 'Your comment has been registered; } else if(btn == 'submitSecond'){ file = 'insertSecond.php'; Msg = 'Your report has been registered; } var data = $('#messageboard').serialize(); $.post (file,data, function(){ alert(Msg); $('#messageboard').each (function(){ this.reset(); }); }); return false; }); }); }); }); }); }); </script> <body> <input type="button" name="submitmessage" id="sumitmessage" value="Add Message"> <div id="txtHint"></div> And then message board is: Code: <form action="" name="messageboard" id="messageboard" method="post"> <input type="text" name="subject" id="subject" value="Subject" /> <br /> <br /> <textarea rows="5" cols="40" name="message" id="message"></textarea> <br /> <br /> <input type="button" name="submitFirst" id="submitSecond" value="Send"> <input type="button" name="subitSecond" id="submitSecond" value="Report"> <br /> </form> This isn't the final form I shall be using, hence some of the names, I stripped back the form to basics to try and get it working in principle (and failed). So what I want to happen is the visitor clicks on the Add Message button (this will be from a list of choices) and then the messageboard form is called - it works up until here - then the visitor fills out the form and decides whether the want to send or report it. It is here that nothing happens, e.g. if the visitor clicks on either the report or send button there is nothing. If I have the form directly in the first page then this all works fine, it is just when I want to have an event calling the form that it doesn't work. As a very small aside, I took this bit of code $("txtHint").html(result){ from a tutorial which originally had the code phrased as $("div").html(result){ . The problem I have is that I have a number of divs with different names, so I tried to identify my div by using it's id "txtHint", the correct page is still being called but it is not being posted inside my div txtHint, the correct way of doing this would be appreciated. Hi, all~..According to ECMAScript, the root of the prototype chain is Object.Prototype. Each object has an internal property [[Prototype]] that could be another object or NULL.... However, it also says that every function has the Function prototype object: Function.Prototype, it confused me, because a function is an object, for a function object, what is its function prototype and object prototype..For example: Code: var x = function (n) {return n+1;}; what is the relationships of x, Object.Prototype and Function.Prototype Thx a lot !!!!!!!!! I had this filterable thing working perfectly but seem to have done something that just makes all the items flash constantly when you try and filter (click the blue section All | Illustration | Animation). Can someone take a look and help at all? http://bit.ly/4yWiDZ Hi all, I have found a nice mootools script and it's using the 1.2.4 version of mootools. The problem is that my website is already using the 1.12 version. Is it possible to change the code and make it compatible with 1.12? My knowledge in javascript is poor and I can't spot the changes that need to be done here. Can you help me please? Code: window.addEvent('domready',function() { (function($) { /* for keeping track of what's "open" */ var activeClass = 'dropdown-active', showingDropdown, showingMenu, showingParent; /* hides the current menu */ var hideMenu = function() { if(showingDropdown) { showingDropdown.removeClass(activeClass); showingMenu.setStyle('display','none'); } }; /* recurse through dropdown menus */ $$('.dropdown').each(function(dropdown) { /* track elements: menu, parent */ var menu = dropdown.getNext('div.dropdown-menu'), parent = dropdown.getParent('div'); /* function that shows THIS menu */ var showMenu = function() { hideMenu(); showingDropdown = dropdown.addClass('dropdown-active'); showingMenu = menu.setStyle('display','block'); showingParent = parent; }; /* function to show menu when clicked */ dropdown.addEvent('click',function(e) { if(e) e.stop(); showMenu(); }); /* function to show menu when someone tabs to the box */ dropdown.addEvent('focus',function() { showMenu(); }); }); $$('#close').addEvent('click',function(e) { hideMenu(); }); })(document.id); }); Hi, I'm trying to build this site that has an accordion styled navigation but there's one little issue. As each div is resizing, they're jittering (take a look at the site: http://balancehair.matcamp.com/) The code I'm using to achieve it is as follows: Code: var all_fields = new Array('home','about','services','gallery','promos','contact'); function hoverRun(fieldName) { for(var t=0;t<all_fields.length;t++) { if(all_fields[t]!=fieldName) { $('box_'+all_fields[t]).style.backgroundImage = 'url(/images/img_'+all_fields[t]+'_inactive.jpg)'; $('tab_'+all_fields[t]).src = '/images/tab_inactive.png'; $('text_'+all_fields[t]).src = '/images/tab_'+all_fields[t]+'_inactive.png'; $('box_'+all_fields[t]).set('morph', {duration: 500, transition: 'linear'}); $('box_'+all_fields[t]).morph({width: 144}); } } $('box_'+fieldName).style.backgroundImage = 'url(/images/img_'+fieldName+'_active.jpg)'; $('tab_'+fieldName).src = '/images/tab_active.png'; $('text_'+fieldName).src = '/images/tab_'+fieldName+'_active.png'; $('box_'+fieldName).set('morph', {duration: 500, transition: 'linear'}); $('box_'+fieldName).morph({width: 240}); } Possibly I'm going about it the wrong way? Any suggestions would be greatly appreciated! I only dabble in a little bit of MooTools so I'm not the greatest at it Thanks! mb89 |