tags:

views:

26

answers:

1

Hello,

I have a table and for every row I would like to create a dialogue box and a link that can be clicked to launch that dialogue box.

E.g. Name 1 (click to get more details). { these are the details for name 1} Name 2 (click to get more details). { these are the details for name 2}

So I would need a dialogue function that I can pass a custom title and body to... And then call that on the click of a link Click here to launch dialogue

I hope I have made myself clear.

Many Thanks, JPH

+1  A: 

I think this will do what you asked for:

<DIV id="MyDialog">

</DIV>

<SCRIPT>
    $(function() {
        $("#MyDialog").dialog({autoOpen: false});
    });

    function showdialog (title, body) {
        $("#MyDialog").html(body);
        $("#MyDialog").dialog("option", "title", title);
        $("#MyDialog").dialog('open');
    }

</SCRIPT>
Jochem
I have this: DO UNTIL rsRetrievePersonalStatementsAwaitingModeration.EOF personalStatement = rsRetrievePersonalStatementsAwaitingModeration("Body") %> <!-- Dialogue Call Start --> <DIV id="MyDialog"> </DIV> <a href="callDialogue(<%=rsRetrievePersonalStatementsAwaitingModeration("Body") %>)"> Click for more details </a> <!-- Dialogue Call End --> <% rsRetrievePersonalStatementsAwaitingModeration.MoveNext indexVariable = indexVariable + 1LOOPDo you see my Dilema?
J Harley
Place the <DIV id="MyDialog"> outside the loop! After document is loaded ($(function() {...});) it's turned into a dialog (but kept hidden, hence autoOpen: false, until you need it). This dialog is (re-)used every time a user clicks.
Jochem
Hey - I realise that the code wont work - its just a bit of Pseudo coding. Right so if I have the div outside of the loop - how would I change the value of the dialogue box?Thanks for your help thus far, JPH
J Harley
Well, it's more than pseudo but you indeed need to integrate it into your own code. So the <DIV> should be somewhere within in your <BODY> tag. The <SCRIPT> you can place inside your <HEAD> tag, perhaps you already have a <SCRIPT> tag there, maybe you even have a $(function() {}) already, you can integrate the 2 then. And for your question: now you can show a dialog by calling the JavaScript function like this: showDialog('Just a title', 'Body, blabla can be HTML blabla'). For instance, you can do this by changing the href to: href="javascript:dialog('<% somestuff %>', '<%some more stuff%>')
Jochem
Hello, We are really getting there, this: "showDialog('Just a title', 'Body, blabla can be HTML blabla')." is exactly what I require... and would this be able to handle HTML characters?Now I then add : "<a href="href="javascript:dialog('<%= titleVariable %>', '<%=bodyVariable%>"..., I understand but do I still require a div even though I am passing the values through Javascript?
J Harley
Yes, you still need the `div` that the dialog will use. This has to either already exist in your code, or get created via javascript prior to calling the dialog on it. I also suggest that you use something like http://jsfiddle.net/ to show your code (changes) rather than trying to show through comments (as they are quite hard to read).
Blair McMillan
Hey guys - I have got it figured. Many Thanks for the assistance.
J Harley
That works well, has anyone any idea how to get Tiny MCE only to load once you have clicked to open a dialogue and to close after the dialogue has been closed?
J Harley
I don't fully understand your question and the relation to the previous question / solution...perhaps you should just ask a whole new question on stackoverflow? That way at least a lot more people will read it!
Jochem
Thanks - will do.
J Harley