开发者

Struts-jquery dialog confirm + link id

I am using struts2-jquery and I am trying to create a modal dialog box for confirmation purposes to delete something. I don't know how to pass the id or upon 'OK' to complete the action.

Below is my code to create the dialog based on struts2-jquery:

<sj:dialog
    id="anchordialogconfirm"
    buttons="{
            'OK':function() {               
                //id of link is needed to c
                $(this).dialog('close');
            },
            'Cancel':function() {  $(this).dialog('close'); }
            }"
    resizable="false"
    autoOpen="false"
    modal="true"
    title="Remove?"
>
 Are you s开发者_C百科ure you want to remove it?
</sj:dialog>

<sj:a openDialog="anchordialogconfirm" id="71" cssClass="deleteemp">Delete</sj:a>

Obviously if I put the href='' into the anchor then the dialog opens to that link rather than getting a modal confirmation dialog.

How can I retrieve the id of the anchor? I want the id of the link for delete or at least suppress the link from being engaged until it is 'OK' to do so.


You could use an auxiliar variable to hold the data sent to the dialog.

In the link you'd put something like this:

<sj:a openDialog="anchordialogconfirm" onclick="aux=%{#attr.obj.id};" href="#">Remove<sj:a>

And you' wait for that value in your dialog:

<sj:dialog
            id="anchordialogconfirm"
            buttons="{
            'OK':function() {
            $('#main').load('yourUrl.action?id='+aux);
            $(this).dialog('close');
            },
            'Cancel':function() {  $(this).dialog('close'); }
            }"
            resizable="false"
            autoOpen="false"
            modal="true"
            title="Remove?"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜