aizaz
aizaz

Reputation: 3062

jquery.min.js Conflicts

When I add the below script ,it effecting other functionality of the project(Spring Application)

  <script type="text/javascript" src="${ctx}/js/jquery-1.3.2.min.js"></script>

My Code

    <script type="text/javascript" src="${ctx}/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/easy.notification.js"></script>
    <script type="text/javascript">

    $.noConflict();

    $(function() {
            $("input[type='text']").blur(function() {

                if (this.value === '') {
                    $.easyNotificationEmpty('Warning : You left this field empty !');
                } else {
                    $.easyNotification('Saved Successfully !');
                }
            })
        });
</script>

I suspect that it because of the conflict of jquery-1.3.2.min.js

I have tried $.noConflict();, but am not getting desired results.

Please help me to resolve this problem, Thanks in advance.

Upvotes: 1

Views: 5451

Answers (5)

user3741526
user3741526

Reputation: 1

I use with TRUE,... this work!:

//your old plugin here


<script type="text/javascript">

$.noConflict(true);

</script>

// new plugin here 

Upvotes: 0

user2050393
user2050393

Reputation:

Try implementing jQuery.noConflict on the alias you'll be using on the script that causes other scripts to break.

var someAlias = $.noConflict();

And use someAlias instead of $ on the script that causes the problem.

Upvotes: 2

Chamika Sandamal
Chamika Sandamal

Reputation: 24312

Try this,

jQuery(function($) {
    $("input[type='text']").blur(function() {

        if (this.value === '') {
            $.easyNotificationEmpty('Warning : You left this field empty !');
        } else {
            $.easyNotification('Saved Successfully !');
        }
    })
});

Upvotes: 8

user2473569
user2473569

Reputation: 31

Use $.noConflict(); before you include new jquery plugin like below,

//your old plugin here

<script type="text/javascript">

$.noConflict();

</script>

// new plugin here 

//new script here

Upvotes: 3

A. Wolff
A. Wolff

Reputation: 74420

You could test that and see if this makes any difference:

(function ($) {
    $(function() {
            $("input[type='text']").blur(function() {

                if (this.value === '') {
                    $.easyNotificationEmpty('Warning : You left this field empty !');
                } else {
                    $.easyNotification('Saved Successfully !');
                }
            })
        });
})(jQuery.noConflict(true))

For example:

http://jsfiddle.net/6zXXJ/

Upvotes: 1

Related Questions