4

All of the places where I was (successfully) setting jQuery UI Dialog button text have stopped working. The buttons appear and they function correctly however no text is displayed in all browsers tested (IE, Safari, Chrome, Firefox & Opera). Using Chrome's inspector and Firebug it appears that the text is not even set on the button instead of it being a CSS issue).

The only thing which has changed recently is that we have moved to jQuery 1.8.0 with jQuery UI 1.8.22 and are not in a position to downgrade again.

A reduced example can be found on jsFiddle http://jsfiddle.net/F7pGu/

Sample HTML:

<div id="form">
    <h1>Blah</h1>
</div>

<button id="array-test">Array Test</button>
<button id="object-test">Object Test</button>

Sample JavaScript:

var $form = $('#form'),
    $arrTest = $('#array-test'),
    $objTest = $('#object-test');

$arrTest.click(function(){
    $form.dialog({
        buttons: [
            {
                text: 'Cancel'                
            },
            {
                text: 'Save'
            }
        ]
    });
});

$objTest.click(function(){
    $form.dialog({
        buttons: {
            'Cancel': function () {},
            'Save': function () {}
        }
    });
});
​

I cannot find anything wrong reading the documentation. We always used the object-test method but the documentation now mentions the array-test method instead.

1
  • @DavidThomas which browser/OS? I've tried on a Windows 7 box, an iPad and an iPhone to no avail. Which test worked? Did both work? Commented Aug 12, 2012 at 10:13

2 Answers 2

7

I did some research as that is an odd issue indeed. Turns out to be a known issue and a bug-tracker has been created for it.

Here is the bug-tracker explaining the issue and the current workaround.

For convinience here is the direct link to the ticket itself which has already been fixed and set to be included in the 1.8.23 release.

Adding the following line of code to your script will make the dialog work again:

if ( $.attrFn ) { $.attrFn.text = true; }

See DEMO

Here is also the additional SO Post which is linked in the bug-tracker.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks - couldn't find the previous SO Post.
@Metalshark: Same here, I found the bug-tracker first and only the SO Post for it after as it was linked in the comments of the bug-tracker.
0

A much simpler solution is to use this snippet after including the jQuery library:

if ( $.attrFn ) { $.attrFn.text = true; }

Here is the corrected working fiddle for you. Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.