Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2011, 08:20 AM   PM User | #1
Cronnie
New to the CF scene

 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Cronnie is an unknown quantity at this point
Javascript variable not resolving, appears as a blank or null

I am currently working on a YUI Progress Bar for a profile page on a portal, and have run into trouble getting the bar to update after an AJAX call.

This is the initial code in the view.jsp which renders the progress bar on page load;

Code:
var pb = new YAHOO.widget.ProgressBar({value:<c:out value="${percentage}" />,minValue:0,maxValue:100}).render('divid');
When users edit a field on the page, there is an AJAX call to update the fields and also the percentage value of profile completion.

There is a function that is also run here, which should update the progress bar, but it isn't working.

Code:
function() {
          items = this.get('responseData');
          var percentage = items[0].value;
          document.getElementById('percent').innerHTML = percentage + '%';
          var element = document.getElementById("divid");
          element.innerHTML = "";
          renderProgressBar(percentage, "divid");
       }
 
function renderProgressBar(percentage, id){
alert(percentage);
 
var pb = new YAHOO.widget.ProgressBar({value:10, minValue:0, maxValue:100}).render(id);
pb.set('value', percentage);
 
}
The percentage value is being updated, as I'm updating the innerHTML of the 'percent' div, and it is correctly updating.

I also display an alert in the renderProgressBar to make sure the value is correct there also.

When it comes to updating the bar however, it just doesn't work, the value is always null or empty.

Any ideas?

I also tried to hardcode adding an entirely new progress bar after clearing the div tag, here is the output when the page is rendered;

Code:
YAHOO.widget.ProgressBar({value:, minValue:0, maxValue:100}).render('divid');
As you can see, the value is empty.
Cronnie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:37 AM.


Advertisement
Log in to turn off these ads.