简体   繁体   中英

jquery-ui-progressbar to recure…repeat a 2nd time

I've got a little problem with the progressbar from jquery-ui. here is the original: http://jqueryui.com/progressbar/#download and here my script: https://jsfiddle.net/soyyo/j3xq65s3/6/ . I would like that after the script is finishing it runs again when close, but how I'm new in javascript I've got a little chaos in my script.

thank you very much indeed for taking action on this matter

hi Rguarascia, thank you for your attention. what you see in jsfiddle is 2xtimes the same script, but a little bit changed by my self. i don't want it running 4 times. all i did was giving the function at the 2nd place the name function inst , and insted for click: closeDownload in the 1st. function I wrote click: inst . then I pasted an other progressTimer function with 5000millisec . under click: inst . i hope you understain my english.

thank you

here is the original:

$(function() {
var progressTimer,
  progressbar = $( "#progressbar" ),
  progressLabel = $( ".progress-label" ),
  dialogButtons = [{
    text: "Cancel Download",
    click: closeDownload
  }],
  dialog = $( "#dialog" ).dialog({
    autoOpen: false,
    closeOnEscape: false,
    resizable: false,
    buttons: dialogButtons,
    open: function() {
      progressTimer = setTimeout( progress, 2000 );
    },
    beforeClose: function() {
      downloadButton.button( "option", {
        disabled: false,
        label: "Start Download"
      });
    }
  }),
  downloadButton = $( "#downloadButton" )
    .button()
    .on( "click", function() {
      $( this ).button( "option", {
        disabled: true,
        label: "Downloading..."
      });
      dialog.dialog( "open" );
    });

progressbar.progressbar({
  value: false,
  change: function() {
    progressLabel.text( "Current Progress: " + progressbar.progressbar( "value" ) + "%" );
  },
  complete: function() {
    progressLabel.text( "Complete!" );
    dialog.dialog( "option", "buttons", [{
      text: "Close",
      click: closeDownload
    }]);
    $(".ui-dialog button").last().focus();
  }
});

function progress() {
  var val = progressbar.progressbar( "value" ) || 0;

  progressbar.progressbar( "value", val + Math.floor( Math.random() * 3 ) );

  if ( val <= 99 ) {
    progressTimer = setTimeout( progress, 50 );
  }
}

function closeDownload() {
  clearTimeout( progressTimer );
  dialog
    .dialog( "option", "buttons", dialogButtons )
    .dialog( "close" );
  progressbar.progressbar( "value", false );
  progressLabel
    .text( "Starting download..." );
  downloadButton.focus();
}

});

but I have seen now that jquery-ui changed the script since today.

what i was trying to do with that script is that on the end it repeats again, only with changes on the label text. 1. run as download, 2nd run as installation.

thank you

hi...its me again with the same problem.

someone was helping me with the result that the code is much shorter, which is also a little succes, but the main problem is not resolved. when the 2. progresstimer is running it appears false% in the labeltext, appbutton is not anymore focus on the end and i cant size the new opening window. see here: @jsfiddle . thank your for your attention. have a got one.

The link you gave does run twice the progress bar twice? Would you like it to run the whole thing again? (so a total of 4 times?)

Some more information could be helpful.

I would comment this but you need 50> rep to do that and I do not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM