简体   繁体   English

进度条与百分比jquery移动

[英]progress bar with percentage jquery mobile

I am trying to develop a mobile application using jquery mobile, as I am doing the work with the web service. 我正在尝试使用jquery mobile开发移动应用程序,因为我正在使用Web服务。 I want it to display a progress bar with percentage of completion. 我希望它显示一个完成百分比的进度条。

Full disclosure: I have written this open source plugin 完全披露:我已经编写了这个开源插件

You may try the jQuery-Mobile-Progress-Bar-with-Percentage plugin. 您可以尝试使用jQuery-Mobile-Progress-Bar-with-Percentage插件。

The jQuery-Mobile-Progress-Bar-with-Percentage (Tolito Progress Bar) is a plugin for jQuery Mobile which creates, manages, starts, stops, resumes and explicitly sets the value of a progress bar. jQuery-Mobile-Progress-Bar-with-Percentage(Tolito Progress Bar)是jQuery Mobile的一个插件,可以创建,管理,启动,停止,恢复和显式设置进度条的值。 In addition the constructor provides the options to set the progress bar's outer theme and inner filling theme on the basis of the jQuery Mobile standard themes, to show a percentage completion counter, to set whether the progress bar has normal or mini size, to define the interval which specifies the filling frequency rate, to configure the max value of the outer bar and set the initial value of the filling inner bar. 此外,构造函数提供了在jQuery Mobile标准主题的基础上设置进度条的外部主题和内部填充主题的选项,以显示百分比完成计数器,设置进度条是否具有正常或迷你尺寸,以定义间隔,指定填充频率,配置外部条的最大值,并设置填充内部条的初始值。 The JavaScript prototype chaining method has been used in order to enable the chaining of separate method calls where each call is made on the same instance. 已使用JavaScript原型链接方法,以便能够链接单独的方法调用,其中每个调用都在同一实例上进行。

EDITED: The new version 1.0.3 contains functionality to stop and/or resume the progress bar and to explicitly set the progress bar's value . 编辑:新版本1.0.3包含停止和/或恢复进度条以及显式设置进度条值的功能 This fits to the cases where some AJAX requests need to be performed and in each successful response the progress bar value has to be set explicitly in order to represent the actual progress status. 这适用于需要执行某些AJAX请求的情况,并且在每个成功响应中,必须明确设置进度条值以表示实际进度状态。 Furthermore an event is triggered when the progress bar is completed. 此外,当进度条完成时会触发事件。

The JavaScript prototype chaining method has been used in order to enable the chaining of separate method calls where each call is made on the same instance. 已使用JavaScript原型链接方法,以便能够链接单独的方法调用,其中每个调用都在同一实例上进行。

The following piece of code configures, builds and initializes a progress bar: 以下代码配置,构建和初始化进度条:

TolitoProgressBar('progressbar')
    .setOuterTheme('b')
    .setInnerTheme('e')
    .isMini(true)
    .setMax(100)
    .setStartFrom(0)
    .setInterval(10)
    .showCounter(true)
    .logOptions()
    .build()
    .run();

Example with mini progress bar: 迷你进度条示例:

在此输入图像描述

Example with a normal progress bar inside a dialog: 对话框中具有正常进度条的示例:

在此输入图像描述

Example with an overlay which includes a normal progress bar: 包含正常进度条的叠加示例:

在此输入图像描述

Try this: 尝试这个:

CSS CSS

.progress { position:relative; width:260px; border: 1px solid #ddd; padding: 1px; border-radius: 3px; }
.bar { background-color: #B4F5B4; width:0%; height:20px; max-width:240px; border-radius: 3px; background-image: url(../images/pbar-ani.gif); }
.percent { position:absolute; display:inline-block; top:3px; left:48%; }

JS JS

Change duration parameter to your estimated time. 将持续时间参数更改为您的估计时间

$(".bar").animate({width:'100%'},{duration:5000,step:function(now,fx){
    var pc = parseInt(now)+'%';
    $(".percent").html(pc);}
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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