views:

43

answers:

1

I have a page with anchor tags that are being converted to JQuery UI buttons via the following code.

$(document).ready(function() {
  $('a.jquery-button-add').button({ icons : { primary: 'ui-icon-circle-plus' } });
});`

For some reason, the icon is only visible on the button when I hold the mouse button down. Without holding the mouse down on the button, the icon is invisible.

This is occurring in all browsers.

Help would be greatly appreciated :)

EDIT: This is the exact code I am using to test this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="css/jquery-ui-overcast.css" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"&gt;&lt;/script&gt;
<script type="text/javascript"> 
    <!-- jQuery click buttons -->
    $(document).ready(function() {
        $('a.jquery-button-add').button({ icons : { primary: 'ui-icon-circle-plus' } });
        $('a.jquery-button').button();
    });

</script>
</head>

<body>
<a href="#" class="jquery-button-add">My nice button</a>
</body>
</html>
+1  A: 

You must have something in addition to the standard jQuery UI CSS that's interfering, here's your code in a very simple test case working.

It's a <span> within an anchor, like this that results:

<a class="jquery-button-add ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon" href="#" role="button" aria-disabled="false">
  <span class="ui-button-icon-primary ui-icon ui-icon-circle-plus"></span>
  <span class="ui-button-text"></span>
</a>

Make sure that you don't have additional styles interfering with that first <span>'s size, display:block; or overflow: hidden;, that's usually what causes .button() issues.

Nick Craver
May i ask how you got a personalized name on jsfiddle please?
RobertPitt
@RobertPitt - It was an alpha test phase where users were manually created to test a few bits...there will be a beta soon with many additional features, including automated account creation to allow everyone who wants to do the same :)
Nick Craver
Thank you Nick :)
RobertPitt
Thanks for the reply. Unfortunately still having problems. I have added the exact code to original question. No icon :S
Nick Barrett
@Nick - Which browser is this happening in? Here's your code running: http://jsfiddle.net/nick_craver/M8Ttc/2/ is it possible the jQuery UI CSS you have is for an older version of jQuery UI?
Nick Craver
Very strange! I changed the jquery-ui css file to the one hosted on google and now the icons are showing. No idea why, as the css file I downloaded was fresh from jquer-ui's website. Nevertheless its working now, thanks!
Nick Barrett