views:

143

answers:

1

Hello everyone! I've done a dialog box that contains a form inside it, and I would like to add some jquery fancy items to it. I've been trying with $().buttonset() as I've done with most of my radio buttons in the application, in order to get a coherent IU for my application. The thing is that, even if following the rules specified, the buttons remain as a normal radio button, and not with the fancy interface. Do you know what could be the problem?

This is the part of the form where I want the fancy radio buttons:

<div id ="Replace">
    <input type="radio" name="Replace" value = "true"  id = "ReplaceYes" 
           onclick = "setReplace(this)" />
    <label for="ReplaceYes">Yes</label>
    <input type="radio" name="Replace" value = "false" checked="checked" 
           id = "ReplaceNo" onclick = "setReplace(this)" />
    <label for="ReplaceNo">No</label>
</div> 

And then, as the previous part of code is in a partial view, invoked when showing the modal box, this is how I try to convert the buttons appearance:

$("#Replace").buttonset();

The thing is that, debugging it I've seen that it goes through that part of the code, but it doesn't do what it's meant to do. Any clue?

Thanks everyone for your attention, vikitor

+1  A: 

Updated: I had never used .buttonset() before, in any case it works against your markup, you can see a demo here. This demo uses the same code as the question:

$("#Replace").buttonset();

Make sure you're including the jQuery UI CSS correctly, and that your IDs are unique, if they are not you'll get some real funny behavior, and should switch to a class. Also, ensure that this part of your view is in the DOM when it runs, e.g. is it inside a document.ready event handler like this?

$(function() {
 $("#Replace").buttonset();
});
Nick Craver
take a look at this, http://jqueryui.com/demos/button/#radio as this is what I want to do. buttonset() exists and it makes a really fancy effect for radioButtons. I've used it in my whole application, but I've encountered the problem when trying to use it in a modal dialog box. As it looks to be something really new, I haven't found anyone with the same problems googling.Thank you for answering anyway :)
vikitor
@vikitor: It works in the demo here: http://jsfiddle.net/WjqVc/ Is that what you're after?
Nick Craver
@Nick: Yes, it works perfectly in that situation, as I said, I have used it successfully in my application. The problem is that, when that part of code is loaded in a jquery dialog modal box, it does nothing, I mean, it just don't convert the buttons as it does in the example you linked :). The thing I'm after is to make it work inside a modal dialog box, because now, with that code, I get the normal radio buttons
vikitor
@vikitor - Did you try running it in the `open` event of the dialog instead of on page load? Here's an example: http://jsfiddle.net/sH2Mz/
Nick Craver
@Nick: Yes, that was the first thing that came into my mind, I tried it with no luck, so I think there must be some kind of incompatibility (probably something to do with CSS) that I haven't been able to fix. Thanks, I think I will try to ask also in the jquery forums, in case it is a bug they will solve it :D
vikitor
@vikitor: If you have a public URL I can hit please comment here, I'll take a look as well.
Nick Craver
@Nick: unfortunately I can't, but I've tried with a simpler version of the functionality, just a modal box with radio buttons to display, and it doesn't work, so I don't know exactly what could happen. Thanks again for your interest
vikitor