javascript - Bootstrap Filestyle - Changing button text for file field doesn't work - Stack Overflow

I would like to change button text for file field in Bootstrap Filestyle plugin in Bootstrap 2.3.2, but

I would like to change button text for file field in Bootstrap Filestyle plugin in Bootstrap 2.3.2, but it doesn't work and text of button is still default. I create file field by replacing element in jquery and tried to set text by attribute data-buttonText or method $("#changeAccountsSourceModal :file").filestyle('buttonText', 'Choose address');

jsfiddle sample

File field

$("#changeAccountsSourceModal .form-horizontal").replaceWith("<input type=\"file\" class=\"filestyle\" data-input=\"true\" data-buttonText=\"Choose address\">");

$("#changeAccountsSourceModal :file").filestyle();

I would like to change button text for file field in Bootstrap Filestyle plugin in Bootstrap 2.3.2, but it doesn't work and text of button is still default. I create file field by replacing element in jquery and tried to set text by attribute data-buttonText or method $("#changeAccountsSourceModal :file").filestyle('buttonText', 'Choose address');

jsfiddle sample

File field

$("#changeAccountsSourceModal .form-horizontal").replaceWith("<input type=\"file\" class=\"filestyle\" data-input=\"true\" data-buttonText=\"Choose address\">");

$("#changeAccountsSourceModal :file").filestyle();
Share Improve this question asked Nov 8, 2014 at 13:13 MattMatt 8,99235 gold badges133 silver badges242 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Just tried it out by passing the option in an object on initiating filestyle, works.

$("#changeAccountsSourceModal :file").filestyle({buttonText: 'Choose address'});

Ironically when you try to change the vaule afterwords the text just gets added to the button.

$("#changeAccountsSourceModal :file").filestyle('buttonText', 'Choose address');

fiddle

working fiddle

You can change button text, remove icon, placeholder and more

$(document).ready(function () {
    $("#myInputId").fileinput({
        mainClass: "input-group-md",
        showUpload: false,
        previewFileType: "image",
        browseClass: "btn btn-sucess",
        browseLabel: "Select Photo",
        browseIcon: "<i class=\"icon-picture\"></i> ",
        removeClass: "btn btn-danger",
        removeLabel: "Delete",
        removeIcon: "<i class=\"icon-trash\"></i> ",
        uploadClass: "btn btn-info",
        uploadLabel: "Upload",
        uploadIcon: "<i class=\"icon-upload\"></i> ",
        msgPlaceholder: "Select Photo"
    });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745281975a4620328.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信