4

For a form, I have a submit button, that posts a form using ajax. When this form is loading, I want to display a spinner right next to the button. This may seem like this question: jQuery UI Dialog, adding elements next to a button, but the difference is that in that post, the question is to display an icon in the left corner. Plus, the solutions proposed aren't working for me.

I have tried the following (from the other thread):

var $respond_dialog = $( "#respond_div" ).dialog({
        width: 500,
        autoOpen: false,
        resizable: true,
        modal: true,
        buttons: {
            "Reageren": function() {
                            $('<div style="width:20px;height:20px;float:right;" 
                            class="ui-autocomplete-loading"></div>').insertBefore(
                            $("#respond_div").next('.ui-dialog-buttonpane > button:first'));
                   ...

but this does nothing. If I remove the >, I get a spinner, but it is displayed like this:

wrong location

How can I fix this?

edit: What I want is this: correct location

Fiddle: http://jsfiddle.net/vpwjw/10/

1 Answer 1

1

The other example was not dealing with a button set which you are, that is why the < returns nothing,

$('<div style="width:20px;height:20px;float:left;" class="ui-autocomplete-loading"></div>')
 .insertBefore('#respond_div .ui-dialog-buttonpane button:first');

You can just use 1 selector to get the right location. Also note, float:left;

You will also need to adjust your padding to center it.

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

3 Comments

I am not seeing anything if I try this. Any ideas why that may be?
Not without a fiddle, I'm just guessing as to your structure right now.
I have edited my question, so that it shows the structure I am using. It also shows what I am trying to achieve.

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.