Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

Jquery ui dialog-window

Hello experts.
I want to use the jquery ui dialog to load a page (ajaxpage.cfm) with a dynamic content every 30 sec.My ajaxpage.cfm has the new records inserted in my db.
there is a query (getlastartikel) and the output of the query.
If getlastartikel.recordcount is 0 (that means that there are no any new records in my db ,i don't want to open the pop up window.
A similar function to this but with xml is here:https://www.experts-exchange.com/questions/25888121/Use-jquery-ui-dialog-instead-of-windows-alert-window.html
(below is a test code that i'm using to show a dialog that call's another page,That what is missing and should be different is instead to click on the link,open automatic the window every 30 sec if a new record exists)
Any help:

<div id="newinserts" title="New Inserts"></div>
<script type="text/javascript">
$(function(){
        // Dialog                       
        $('#newinserts').dialog({
                autoOpen: false,
				bgiframe:true,
				modal:true,
                width: 400,
                height: 240,
				modal: true,
              //  open: function(event, ui) {initialize();}, // this will load google map in the dialog window
                buttons: {
                        "OK": function() { 
						       
                                $(this).dialog("close"); 
                        }, 
                        "Cancel": function() { 
                                $(this).dialog("close"); 
                        } 
                }
        }); 
          // Dialog Link
             $('#dialog_link').click(function(){
               $('#newinserts').dialog('open');
               $('#newinserts').load("../user/ajaxpage.cfm");
                   return false;
                });
 });
</script>

Open in new window

Avatar of StealthyDev
StealthyDev

can you expose your cfm file to www?

say,

http://www.xyz.com/abc.cfm
Avatar of Panos

ASKER

Hi again
Do you want me to build an output in html to help you?
Hi again.

I need a sample output of "../user/ajaxpage.cfm" as in your example.

Avatar of Panos

ASKER

OK
wait a moment
Avatar of Panos

ASKER

see attached code
testcode.txt
ASKER CERTIFIED SOLUTION
Avatar of StealthyDev
StealthyDev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Panos

ASKER

Hi.
I did not understand how it works with the hidden field.
I will put in the hidden field the number or records.(the content can be anything,it is a query output)
Now the script must check if the value in the hidden field is >0.

Also i think that it is required an id for the hidden field because i could use a form in the popup window and put there hidden fields too.
You can achieve it in any means, since i have used AJAX, as what we built already, i cant access DOM-for hidden field. So, I have made a string search.

If the string is present in the hidden field, the text in the AJAX response should have it.

Just try running the default.html, placeing ajaxpage.html and jquery in a folder.

Regards.
Avatar of Panos

ASKER

I think i do a mistace.
f.e
if i have 8 records in my ajaxpage   how would be the value for the hidden field?
do i have to copy and paste the script like it is?

...
if(AjaxHTML.indexOf("#123465789#for-telling-page-has-contents###") > 0)
...
Hmm, this is simple,

The only problem we face is, we should not show the dialog if there are no items to display.

For this, i am checking the hidden field.

You need to put "#123465789#for-telling-page-has-contents###" in the hidden field if you want to display the alert. Else leave it empty. :)

Also, make sure that "#123465789#for-telling-page-has-contents###" will not come in your message. So give it as lengthy and non-occurring.

Regards.

Avatar of Panos

ASKER

Now i understand.
I could simple set a value "norecords" for  recordcount 0
and use in the script:
if(AjaxHTML.indexOf("norecords")  > 0)

???
No, if you have norecords as a text in your message, it would cause the messagebox to not to be displayed. (i am telling this due to experience)

So, try to give a strong value.

ie,. norecords = #123465789#for-telling-page-has-contents###


Avatar of Panos

ASKER

OK senthurpandian.
All the comments where very helpful for me.
(by the way: this is working for me #norecords# but i will use your code to be shure!! that it will work.

Thanks alot
Avatar of Panos

ASKER

Thank you very much for your help.
A next question will come for the position of the popup window.
I want to place it to the bottom right corner.
https://www.experts-exchange.com/questions/25907322/Position-jquery-ui-dialog-popup-window.html?fromWizard=true