0

I have dont a smalle web application for a client. I have tested it in firefox, chrome, IE7, IE8 and IE9.

Now I cant get it to fail. Its working in every browser/version I have tested. Im not sure what build my client is sitting with but he said it was IE9.

The code is this:

function noticeBox(type, html, title) {
switch(type) {
    case 1:
    $('#notice_box').dialog({
        title: title,
        width: 400,
        modal: true,
        position: 'center',
        buttons: {
            'Ok': function() {
                $(this).dialog('close');
            }
        }
    });     
    break;
    case 2:
    $('#notice_box').dialog({
        title: title,
        width: 800,
        modal: true,
        position: 'center',
        buttons: {
            'Bekræft og bestil': function() {
                $('#form_products').submit();
            },
            'Annuller': function() {
                $(this).dialog('close');
            }
        }
    });     
    break;
    case 3:
    $('#notice_box').dialog({
        title: title,
        width: 400,
        modal: true,
        position: 'center',
        buttons: {
            'Luk': function() {
                $(this).dialog('close');
            }
        }   
    });
    break;
}
alert(html);
$('#notice_box').html(html);
$('#notice_box').dialog('open'); }

Not a very generic function but thats what is failing at the moment. He says that when the dialog pop's there is no content in the dialog. He can see the buttons but is like there is no html in the dialog it self.

Any ideas?

UPDATE: Btw he can active several dialogs and the result is the same in all of them. Dialogs without any content.

UPDATE2: An example how I use that function is this. When a client orders some products:

function order() {
var procuct_str = '';
var found_order = false;
$.each($('.order_input'), function(){
    var product_id = $(this).attr('id').split('-');
    if(parseInt($(this).val()) > 0) {
        found_order = true;
        procuct_str = procuct_str+'<div class="float_left"><span class="bread_text">'+$('#description-'+product_id[1]).text()+'</span></div><div class="float_right"><span class="bread_text">'+$(this).val()+'</span></div><div class="clear"></div>';
    }
}); 

if(found_order == true) {
    procuct_str = '<div class="float_left"><b>Beskrivelse</b></div><div class="float_right"><b>Antal kasser</b></div><div class="clear"></div>'+procuct_str;

    noticeBox(2, procuct_str, 'Bekræftelse');
    var found_order = false;
} }

2 Answers 2

0

Your html variable needs to be accessed within the scope of the function, unless you've declared it elsewhere. From the code you provided, html is a function argument, and outside the function it will always be 'undefined'.

1
  • It should be I use html in the function function noticeBox(type, html, title) { and when I use html its down at the bottom of the function $('#notice_box').html(html); Mar 25, 2012 at 14:46
0

It works fine for me.

I used your function like this:

noticeBox(1, "<p>Hello</p>", "Test");

What is your client supplying for the html-argument? Some html could possibly mess it up. Or simply maybe your client left it out which would explain why nothing is showing.

7
  • The client dosent control the content the function is putting in... its dynamicly created based on how many products he is ordering. An example would be: Mar 25, 2012 at 14:40
  • <div class="float_left"><b>Beskrivelse</b></div><div class="float_right"><b>Antal kasser</b></div><div class="clear"></div><div class="float_left"><span class="bread_text">Baneguide</span></div><div class="float_right"><span class="bread_text">1</span></div><div class="clear"></div><div class="float_left"><span class="bread_text">Brevpapir A4 m. Fl kort, Vnr. 006</span></div><div class="float_right"><span class="bread_text">1</span></div><div class="clear"></div> Mar 25, 2012 at 14:43
  • Look at the main topic UPDATE 2. Might clarify it better Mar 25, 2012 at 14:48
  • Hm okay. Why do you declare var found_order = false; in the end of your code, shouldn't it be found_order = false; otherwise each time order runs it will open the dialog without content after found_order = true the first time. Mar 25, 2012 at 15:26
  • procuct_str is empty, then this code is run: procuct_str = '<div class="float_left"><b>Beskrivelse</b></div><div class="float_right"><b>Antal kasser</b></div><div class="clear"></div>'+procuct_str; noticeBox(2, procuct_str, 'Bekræftelse'); var found_order = false; Would give you an almost empty dialog. Is your customer seeing the "Beskrivelse" and "Antal Kasser"-texts? Or is the dialog completely empty? Mar 25, 2012 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.