Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

using simpledialog as alert() replacement #14

Closed
mickgol opened this issue Aug 23, 2011 · 5 comments
Closed

using simpledialog as alert() replacement #14

mickgol opened this issue Aug 23, 2011 · 5 comments

Comments

@mickgol
Copy link

mickgol commented Aug 23, 2011

Hey mate,

Great job on simpledialog - its a great plugin :) I'm trying to use it as a replacement for alert() - what i've done is have a HTML simpledialog with a in it, and I set the 's value to my alert message just before showing the simpledialog.

It looks great, but the only problem is that I have a multi-page jquery mobile app, so the simpledialog only works on the page where i opened it first. My simpledialog "alert()" will no longer work when i go to a different page, so I guess the plugin attaches itself to whatever page you called it on first?

Is there any way to make this work so i can just have one simpledialog for multiple pages? Or do I need to attache a simpledialog to each page that might have an alert()?

Thanks,
Michael

@jtsage
Copy link
Owner

jtsage commented Sep 9, 2011

You will need to attach it to multiple pages. Unless you can work out a way to move it, in which case I'm happy to add the function - I use it for pretty much the same purpose, and end up just creating instances on the fly as I need them. Also, unless you are using the blank html mode, simpledialog won't change it's content once initialized - another downside to how I did things - considering working that one out.

@chrismark
Copy link

Hi jtsage.

I would like to know how you're creating your instances on the fly. Do you have to clean up the old markups that you used for showing the dialog?

@chrismark
Copy link

Adding:

this.pickerContent.appendTo(this.thisPage);
this.screen.appendTo(this.thisPage);

right after:

        if ( this.options.isOpen ) { return true; }

then when opening a dialog:

        jQuery('#popupdialog').data('simpledialog').options.fullHTML = fullHTML;
        jQuery('#popupdialog').simpledialog('refresh');
        jQuery('#popupdialog').simpledialog('open');
    }
    else {
        jQuery('body').append('<div id="popupdialog"></div>');
        jQuery('#popupdialog').simpledialog({
            'mode': 'blank',
            'prompt': false,
            'fullHTML': fullHTML
        });
    }

allows me to open my dialog on any page

@vehuel
Copy link

vehuel commented Oct 14, 2011

I think that if the mobile-simpledialog remove himself from the DOM after using it most of the "problems" would be solved.

We could open as many instances as we wanted without problem the window does not refresh some content when reopened or not to open when working with multiple pages.

This is a great plugin and has much potential. I have not quit him after all the difficulties I have had. :)

I'm using this way for now:

var delDialog = function() {
    // Remove temporary div created by me and divs created by mobile-simpledialog 1 sec after dialog close.
    setTimeout(
        "$('#divDialog,.ui-simpledialog-container,.ui-simpledialog-screen,.ui-simpledialog-dialog').remove();",
        1000
    );
}

var openWindow = function(callbackFunction) {
    // Create temp div to bind dialog window before jQuery Mobile loading div
    $('<div id="divDialog"></div>').insertBefore('.ui-loader');

    // Bind dialog window to temporary div
    $("#divDialog").simpledialog({
        'mode': 'bool',
        'prompt': "Test",
        'useDialogForceFalse': true,
        'buttons': {
            'Ok': {
                click: function() { delDialog(); callbackFunction(); }
            }
        }
    });
}

Basically I attached the window in the div and when I click the button I remove the div created by me and created by the mobile-simpledialog.

@jtsage jtsage closed this as completed Nov 3, 2011
@adrianamendoza
Copy link

I need to display more than one confirm popup using an special order, like first popup "A", then "B", and then "C", each one of them must have a confirm button so the next popup will be opened when it is pressed.
I tried with "simpledialog" popup but I got all the three popups overlapped, so at the end I only had the last popup.
I also tried with "simpledialog2" but I had the error "Uncaught TypeError: Cannot read the property 'sdIntContent' of undefined."
Is there a way to open a popup only if there is no open popup?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants