conflict beetween mootols and ajax script - javascript

I am not expert programmer and I need an help.
I have a conflict between these codes:
<script type="text/javascript" src="mootools-1.5.1-core.js"></script>
<script src="src/tooltip.js" type="text/javascript"></script>
the tooltip.js code is in this package:
http://www.menucool.com/download/tooltip.zip
In the project I will need use the jquery also.
Thank you in advance for your help.
A.

If using jQuery and mooTools is a must, you can run jQuery in noConflict mode. The order of the scripts should look like this to work:
<script src"path/to/jquery.js" type="text/javascript"></script>
<script src="src/tooltip.js" type="text/javascript"></script>
<!-- this will make jQuery available through the jQuery variable -->
<script type="text/javascript">$.noConflict();</script>
<script type="text/javascript" src="mootools-1.5.1-core.js"></script>

Related

jQuery $.mobile library is undefined

I have linked jQuery and jQuery mobile to my code. I got this error in the console:
TypeError: $.mobile is undefined
I have rechecked the URL and all are correct, I have update the files(jQuery, jQuery mobile) and the issue is still exists.
I have place the jquery.js before jquery.mobile.js
This is my code:
<script src="JS/jquery.js" type="text/javascript"></script>
<script src="//code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
<script src="JS/bootstrap.min.js" type="text/javascript"></script>
<script src="JS/code.js" type="text/javascript"></script>
and it's on the end of the file.
the content of code.js: http://pastebin.com/3LTcxs9S
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js">
</script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-
1.3.1.min.js"></script>
try this by replacing your code
NOTE* put jquery mobile script at last after putting all jquery library scripts, im sure it will work

How can I use regex to remove scripts from html tag

I'm using WordPress and copy-pasted from an old site a bunch of script tags and now it's loading them to my pages which causes excessive page-load times.
So I want to remove the scripts, but there are a lot of pages and those scripts are inserted into custom fields mixed with the actual text.
I have this search-and -eplace plugin which uses regex but I'm not sure how I can use regex to remove them.
Here's an xample:
<!-- Jquery scripts -->
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="js/jquery.tinyscrollbar.min.js" type="text/javascript"></script>
<script src="js/jquery.tipTip.minified.js" type="text/javascript"></script>
<script src="js/cufon-yui.js" type="text/javascript"></script>
<script src="js/gothanmedium_500.font.js" type="text/javascript"></script>
<script src="js/gothanbold_700.font.js" type="text/javascript"></script>
<script src="js/gothanbook_500.font.js" type="text/javascript"></script>
<script src="js/common.js" type="text/javascript"></script>
<!-- End Jquery scripts -->
I was wondering if I can start the expression from the comment tag <!-- Jquery scripts --> and end with <!-- End Jquery scripts --> so to remove all of them altogether.
Try to use this regex.
|(<!-- Jquery scripts -->[\s\S]+<!-- End Jquery scripts -->)|gim
Example

What is the correct sequence of including jquery files?

Today i wanted to add datepicker() to my page.So I downloaded jqueryui and added then in the sequence below.
<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/superfish.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/retina.min.js"></script>
<script src="assets/validate.js"></script>
<script src="js/jquery.placeholder.js"></script>
<script src="js/functions.js"></script>
<script src="js/wizard_func.js"></script>
<script src="check_radio/jquery.icheck.js"></script>
<script type="text/javascript" src="js/navi_artstyle.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/mapmarker.jquery.js"></script>
<script type="text/javascript" src="js/mapmarker_func.jquery.js"></script>
It didn't work. It took me whole day to figure out what is wrong. it was the SEQUENCE of js files included!!! To work my code i had to include them like bellow.("jquery.js" position had to change)
<script src="js/superfish.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/retina.min.js"></script>
<script src="assets/validate.js"></script>
<script src="js/jquery.placeholder.js"></script>
<script src="js/functions.js"></script>
<script src="js/wizard_func.js"></script>
<script src="check_radio/jquery.icheck.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/navi_artstyle.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/mapmarker.jquery.js"></script>
<script type="text/javascript" src="js/mapmarker_func.jquery.js"></script>
Can some one explain this please. Please give me a Source so I wont make this mistake again.
Normal jQuery (core)
jQuery migrate if you have
jQuery UI
jQuery mobile
Scripts that need jQuery / scripts that are jQuery plugins
Other scripts like bootstrap
You own scripts depending which is needed first
First you have to include normal jQuery library.After that You have to include other jquery library like jquery ui and jquery mobile and all finally you have to include your own javascript files.
As mentioned in comments you have to mention the scripts in the order you use that.
Simply anything used Jquery will goes after jQuery, anything that depends on jQuery UI goes after jQuery UI etc.

Uncaught TypeError: undefined is not a function

I have checked a lot of forums, but i did't find a solution.
site -> http://dszerszen.pl/domi/
and this code
<script type="text/javascript">
$(document).ready(function(){
$(".info").tytabs({
tabinit:"1",
fadespeed:"fast"
});
});
</script>
icon switcher dosent work
Simply rearrange your scripts in this order:
<script type="text/javascript" src="jquery.min.js"></script>
<script src="modernizr.custom.63321.js"></script>
<script type="text/javascript" src="tytabs.jquery.min.js"></script>
<script src="scrolltop.js" type="text/javascript"></script>
<script async src="analytics.js"></script>
The jQuery core library should be included first followed by the other plugin code.
You have defined scrollTop.js in two places.
One is at the top of css files. And jquery is not loaded before that. That's why you are getting error.
<title>Smykke Galleriet</title>
<link type="text/css" rel="stylesheet" href="stylesheet.1.css" />
<script src="scrolltop.js" type="text/javascript"></script>
Remove that line and it will work properly.

Ajax CDN support for ajaxcontroltoolkit

I am using ajaxcontroltoolkit in my web forms application. I have added ToolkitScriptManager in my master page like below;
<ajaxToolkit:ToolkitScriptManager runat="server" />
and the following lines are generated;
<script src="/WebResource.axd?d=Jibl3MtI-Z0SnbWFojUORizoN9Crh5ry8NMfzJSSnoTf-UFTKFjMJ64T1LoJzsMiy-3x84ZOv4fPul5Ovf0hWqKfvas1&t=634361805716190000" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=GaKMM7fT3pJ-STBLsG7RA9G19YL8-8Qwn55cEa789OnUZnJVo7k-lHiGlv-78SX_-jNa1e8ggtiMU1q11qL5p_Ds-x2fGN94tSQ_LiVmXw5rZT5JLvwPijiZtGc4sjeI6qyDWl6iPDaSvOI5BxUFSYMrocQ1&t=ffffffff88dd8486" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=5-e4xi7M2z7nkjzlbU8-TWOpW3pG-5yWTc1gjU27ASzLUO3z3X6ekk3Sni1yPjhQTHZqsYZzKxrYCi_Gka_qck67rCoY74phG4J0hnrafob5PPfGsqMiXsHm5iwUWoAf11fyGw2&t=11e6618b" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=QuFbQ1DExlSpNLIb-yKHF9rpmtXEsaZy3mY1kUywoGagqJwlk39ehRy6UMfloAvfPq5iKspCQd3hr6z2WtLRfs2vX5cK8IhsLTmXS2C608YECG519GPA63CN6_5IYjb9Or0HIg2&t=11e6618b" type="text/javascript"></script>
<script src="/default.aspx?_TSM_HiddenField_=ctl08_HiddenField&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d3.5.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-GB%3a1547e793-5b7e-48fe-8490-03a375b13a33%3ade1feab2%3af9cec9bc%3aca57ef3c%3aab09e3fe" type="text/javascript"></script>
<script type="text/javascript">
Is there any way that I can serve them from Ajax CDN? I am on .net 4. thanks!
EDIT :
here how it looks like after I added EnableCdn property;
<script src="http://ajax.microsoft.com/ajax/4.0/1/WebForms.js" type="text/javascript"></script>
<script src="http://ajax.microsoft.com/ajax/4.0/1/WebUIValidation.js" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=5-e4xi7M2z7nkjzlbU8-TWOpW3pG-5yWTc1gjU27ASzLUO3z3X6ekk3Sni1yPjhQTHZqsYZzKxrYCi_Gka_qck67rCoY74phG4J0hnrafob5PPfGsqMiXsHm5iwUWoAf11fyGw2&t=ffffffffbd2983fc" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=QuFbQ1DExlSpNLIb-yKHF9rpmtXEsaZy3mY1kUywoGagqJwlk39ehRy6UMfloAvfPq5iKspCQd3hr6z2WtLRfs2vX5cK8IhsLTmXS2C608YECG519GPA63CN6_5IYjb9Or0HIg2&t=ffffffffbd2983fc" type="text/javascript"></script>
<script src="/default.aspx?_TSM_HiddenField_=ctl08_HiddenField&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-GB%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3ade1feab2%3af9cec9bc%3aca57ef3c%3aab09e3fe" type="text/javascript"></script>
<script type="text/javascript">
If you're using the .NET 4 version of the Control Toolkit, simply set EnableCdn to true:
<ajaxToolkit:ToolkitScriptManager runat="server" EnableCdn="true" />
This is not possible, the control points to local dynamic files only.
Maybe a better idea is migrate the functions used, to a jquery based alternative with witch you can use a CDN.

Categories