Jump to content

Passing Variables into Modal Dialogue/Window.


tebrown

Recommended Posts

Thanks.

 

It doesn't seem to open up the modal though.

 

jQuery(function ($) {
    $('#basic-modal .basic').click(function (ev) {
        ev.preventDefault();
        $('<div />').load($(this).attr('href')).modal();
    });
});
});

i really don't think it is the JS though. try changing the loop a few time as follows tell me what you get.

 

 

while($rows=mysql_fetch_array($result,MYSQL_NUM) { //output as numerical index
}

 

while($rows=mysql_fetch_array($result,MYSQL_ASSOC) { //output as associative index
}

 

while($rows=mysql_fetch_array($result,MYSQL_BOTH) { //output  both assoc and numerical index
}

 

 

 

I played around with it for a while but easnt working still. I then looked into this forum post:

 

http://stackoverflow.com/questions/8585361/jquery-dialog-box-passing-variable-value-from-php-to-jquery-function

 

So i tried out the iFrame, i got it to work and it now shoes the id for each link.

 

But iFrame's seem to take away my css styling. I've lost all my style within the modal itself.

 

jQuery(function ($) {


        // Load dialog on click
        $('#basic-modal .basic').click(function (e) {
        e.preventDefault();

        // Display an external page using an iframe
        var src = $(this).attr('href');
        $.modal('<iframe src="' + src + '" height="450" width="400" style="border:0">', {

            overlayClose:true
        });

            return false; // not sure why you're doing this
        }); // end of click handler

    });  // end of document.ready

 

 

Ok i found a solution but i'm not sure how safe in regards to coding standards.

 

jQuery(function ($) {

 

// Load dialog on click

$('.basic').click(function (e) {

var id = $(this).attr("href");

$('#showvalue').text(id)

$('#content-one').modal({

overlayClose:true,

opacity:40

 

});

return false;

 

});

 

});

 

When the user clicks a specific fixture from the list, it will open the modal and then show the id number within the div 'showvalue'.

 

To echo it out i did the following.

 

$id = '<div id="showvalue"></div>';

echo $id;

 

Tell me what you think.

 

Cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.