Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery UI Progress Bar Not Working Since NoConflict Added?

Posted on 2014-07-28
4
Medium Priority
?
827 Views
Last Modified: 2014-07-29
Our MVC 5 web uses Jquery 1.11.0 and we're adding a Jquery UI progress Bar which uses Jquery 1.10.2... We want to isolate the progress bar script by encapsulation so any updates via Nuget doesn't interfere...

This Jquery UI Progress Bar worked perfectly until adding $.noConflict() like you see below. I have been to the Jquery web site and found this solution, but It doesn't work...
 
<div>
    <div id="progressbar"><div class="progress-label">Loading...</div></div>
</div> 

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript"> var j$1102 = $.noConflict(true); </script>
<script type="text/javascript" src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script>
    
    (function (jQuery) 
    {
        var percentage = 46;
        var progressbar = $("#progressbar");
        var progressLabel = $(".progress-label");

        progressbar.progressbar({
            value: false,
            change: function () {
                progressLabel.text(progressbar.progressbar("value") + "%");
            },
            complete: function () {
                progressLabel.text("Complete!");
            }
        });

        function progress() {
            var val = progressbar.progressbar("value") || 0;
            progressbar.progressbar("value", val + 1);
            if (val <= 45)
            {
                setTimeout(progress, 80);
            }
        }
        setTimeout(progress, 1000);
    })
        (j$1102);

</script>

Open in new window

0
Comment
Question by:WorknHardr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 40225982
Firstly let's try this as the $ is not available unless you explicitly make it so and you're specifying the variable 'jQuery' not $ as passed to the anonymous function:

Example of using $ as a local variable: http://jsbin.com/fiyaco/1/edit?js,console,output
// change jQuery to $ and it should be used as priority over the global $.  
   (function ($) 
    {
        var percentage = 46;
        var progressbar = $("#progressbar");
        var progressLabel = $(".progress-label");

        progressbar.progressbar({
            value: false,
            change: function () {
                progressLabel.text(progressbar.progressbar("value") + "%");
            },
            complete: function () {
                progressLabel.text("Complete!");
            }
        });

        function progress() {
            var val = progressbar.progressbar("value") || 0;
            progressbar.progressbar("value", val + 1);
            if (val <= 45)
            {
                setTimeout(progress, 80);
            }
        }
        setTimeout(progress, 1000);
    })
        (j$1102);

Open in new window


Any questions, please let me know.
0
 

Author Comment

by:WorknHardr
ID: 40226741
It's working! Here are my latest changes ...

<script src="//code.jquery.com/jquery-1.11.1.js"></script>   //running 'global scope' version...

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>  //using this 'local scope' version
<script type="text/javascript" src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script>

    var j$1102 = $.noConflict(true);

    (function ($) {
      ...
    })(j$1102);

</script>
0
 
LVL 43

Expert Comment

by:Rob
ID: 40228177
Yep - looks good.  Was there anything else related to this I can help with? otherwise just go ahead and close the question.
0
 

Author Closing Comment

by:WorknHardr
ID: 40228231
Thx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question