简体   繁体   English

如何将选定的数据从模式弹出窗口发送回父表单并关闭模式

[英]How do you send selected data back from modal popup to parent form and close modal

I have in my parent form the following code which opens a modal list view of items. 我的上级表单中有以下代码,用于打开项目的模式列表视图。

<?php
    // My Stuff
    $field = $fieldSet['jform_my_stuff'];
    ?>
    <div class="control-group <?php echo 'field-' . $field->id . $field->responsive; ?>">
        <div class="control-label">
            <?php echo $field->label; ?>
        </div>

        <div class="controls">
            <?php echo $field->input; ?>
        <?php
JHTML::_('behavior.modal');
?>
<a class="modal"
<a href="index.php?option=com_popuptry&amp;view=stuff&amp;layout=stuff&amp;tmpl=component" rel="{handler: 'iframe', size: {x: 800, y: 600}}">Select</a>
        </div>

The form looks like this. 该表格如下所示。

父页面

The feild I want the data to be updated to is 我想要将数据更新到的领域是

jform_my_stuff jform_my_stuff

I have tried a number of options but just cannot get the modal to send back the required input 我尝试了很多选项,但无法获取返回所需输入的模态

I replaced all my efforts with some txt for now 我现在用一些txt代替了我所有的努力

模态

The last peice of code would go in here 最后一段代码会在这里

</td>
            <?php endif; ?>

            <td style="text-align:center">
                <?php echo JDom::_('html.fly', array(
                    'dataKey' => 'stuff',
                    'dataObject' => $row
                ));?>


            </td>
            <td style="text-align:center">
            Button here to send selected item (stuff) <br>back to parent feild called jform_my_stuff<br> & close modal
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    endfor;
    ?>
    </tbody>
</table>

I am completely lost as to what I need to put in here as most things have not worked.. ?? 我完全迷失了我需要放在这里的东西,因为大多数事情都没有奏效。 any pointers appreciated. 任何指针表示赞赏。

You would need to use Javascript. 您将需要使用Javascript。 (I use jquery here). (我在这里使用jQuery)。 I'm doing my best to understand what you are trying to do. 我正在尽力了解您要做什么。

Basically, I'd write a function to handle the button click. 基本上,我会编写一个函数来处理按钮单击。

<input type="button" value="Click Me" onclick="sendToMyStuff()">

The function would be as follows: 该功能如下:

function sendToMyStuff(){
    var stuff = $('input[name="checkbox"]:checked').val(); // "stuff"
    $('#mystuff').val(stuff); //Sent the value of the stuff input -- if it is not an input you can use .text()
    $('#modal').hide(); //Hide the modal window
}

You could also simply use the ID of the checkbox to get the data. 您也可以简单地使用复选框的ID来获取数据。 I wasn't exactly sure what you are trying to do. 我不确定您要做什么。 I am also not super familiar with Joomla. 我对Joomla也不是很熟悉。 You could also just bind the button click. 您也可以绑定按钮单击。

$('#button').bind('click', function(){ }

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM