问题描述:

I want to update my code which works well with jquery 1.4.1 to work with jquery 1.10.2.

I searched on google but i didn't find what changes i have to make.

I get the following error:

Uncaught TypeError: Object #<Object> has no method 'photoTagger'

this is the name of the function i want to update.

网友答案:

You should simply use the jQuery migration file, which can be found here: http://code.jquery.com/

Then, you can use the newest jQuery version and your old plugins/jQuery code will still work, eg:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
网友答案:

I would recommend you not to change entire code if it is not that necessary,because many code is dependent on jQuery library and some functions also deprecate and not support in latest versions. You may use multiple jQuery files on same page.

<!-- load jQuery version 1.4.1 -->
<script src="jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
var $jQuery1_4 = $.noConflict(true);// Here you must need to pass true
                                    //else it will only free $ variable
                                    //and using jQuery with blow libraries
                                    //cause conflict
</script>

//you must load second library later after initializing
//first instance of version and freeup jQuery keyword
//else jQuery keyword will
//cause conflict it you uplaoded both files.

<!-- load jQuery version 1.10.0 -->
<script src="jquery-1.10.0.js" type="text/javascript"></script>
<script type="text/javascript">
var $jQuery1_10 = $.noConflict(true);
</script>

//so now here $ and jQuery both cannot be used

//using $jQuery1_10 will call version 1.10.0 library code
$jQuery1_10( "div p" ).show();

//using $jQuery1_9 will call version 1.4.1 library code
$jQuery1_4( "div p" ).show();
网友答案:

In this case the problem wasn't the incompatibilty between the jquery verisons, it was the incorrect order of loading javascript and jquery files and calling of functions. I solved the problem, your answers helped me. Thanks for help!

相关阅读:
Top