JToolbar 前端在点击时提交值

发布于 2024-12-11 07:35:12 字数 2112 浏览 0 评论 0原文

我正在构建一个 joomla 组件,但找不到以下问题的解决方案。在我的前端,我使用 JToolbar 类中构建的 joomlas 来处理单击事件,例如编辑、删除等。

            <form action="<?php echo JRoute::_('index.php');?>" method="post"
                name="termForm" id="adminForm">

                <table class="stripeMe">
                    <tbody>


                    <thead>

                        <tr>
                            <th>Begriff</th>
                            <th>Definition</th>



<?php if ($user->authorize('com_glossary', 'edit', 'glossary', 'all')): ?><th>Published</th> <?php endif; ?>    

        </tr>
                    </thead>

              <?php foreach($this->items as $i => $item): ?>

            <tr> 

                <td>

                <span class="title"><?php echo $item->tterm; ?></span>

                    <?php if ($user->authorize('com_glossary', 'edit', 'bearbeiten', 'all')):?> 

                       <?php echo $this->getEdit(); ?><?php endif; ?>

                </td>

               <td><?php echo $item->tdefinition; ?></td>
                 <?php if ($user->authorize('com_glossary', 'edit', 'bearbeiten', 'all')): ?>
               <td><?php echo $this->getPublished(); ?></td> <?php endif; ?>    


           </tr>
               <?php endforeach; ?>

    </tbody>
    </table>

                <div>
        <input type="hidden" name="task" value="" /> <input type="hidden"
                        name="id" value="" onclick="submitbutton(<?php echo count( $item->id ); ?>);" /> <input type="hidden"
                        name="option" value="com_glossary" /> <input type="hidden"
                        name="controller" value="bearbeiten" />


        <?php echo JHtml::_('form.token'); ?>
    </div>
            </form>

我想将所选行的 id 传递给按钮事件的子控制器,但我真的不知道该怎么做

I'm building a joomla component and I can't find a solution to the following. In my front end I'm using the joomlas build in class JToolbar to handle events on click like edit, delete so one.

            <form action="<?php echo JRoute::_('index.php');?>" method="post"
                name="termForm" id="adminForm">

                <table class="stripeMe">
                    <tbody>


                    <thead>

                        <tr>
                            <th>Begriff</th>
                            <th>Definition</th>



<?php if ($user->authorize('com_glossary', 'edit', 'glossary', 'all')): ?><th>Published</th> <?php endif; ?>    

        </tr>
                    </thead>

              <?php foreach($this->items as $i => $item): ?>

            <tr> 

                <td>

                <span class="title"><?php echo $item->tterm; ?></span>

                    <?php if ($user->authorize('com_glossary', 'edit', 'bearbeiten', 'all')):?> 

                       <?php echo $this->getEdit(); ?><?php endif; ?>

                </td>

               <td><?php echo $item->tdefinition; ?></td>
                 <?php if ($user->authorize('com_glossary', 'edit', 'bearbeiten', 'all')): ?>
               <td><?php echo $this->getPublished(); ?></td> <?php endif; ?>    


           </tr>
               <?php endforeach; ?>

    </tbody>
    </table>

                <div>
        <input type="hidden" name="task" value="" /> <input type="hidden"
                        name="id" value="" onclick="submitbutton(<?php echo count( $item->id ); ?>);" /> <input type="hidden"
                        name="option" value="com_glossary" /> <input type="hidden"
                        name="controller" value="bearbeiten" />


        <?php echo JHtml::_('form.token'); ?>
    </div>
            </form>

I would like to pass to id of the selected row to the sub-controller on button event and I don't really know how to do it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-12-18 07:35:12

这里有一些关于在前端使用 JToolbar 的有用提示 http://docs.joomla.org/How_to_use_the_JToolBar_class_in_the_frontend

我过去曾经做过一次,据我所知,我做了一些技巧才能让它发挥作用。

1.) 首先删除“id”输入并在表单末尾添加以下输入:

<input type="hidden" name="boxchecked" value="0" />

2.) 其次确保 Mootools 已附加到源

3.) 最后:在那里,您开始 foreach 循环的地方,在“之后” tr”标签添加另一个表格列:

 <td><?php echo JHTML::_('grid.id', $i, $item->id ); ?></td>

不要忘记在 thead 中为此列创建一个列标题。

这些步骤将在每行的第一个单元格中创建一个复选框,并使表单能够通过请求发送所选字段的 id

编辑:
tbody 标签位置错误,它应该位于 thead 标签之后。此外,也没有使用将事件附加到隐藏输入,因为它们不会被触发

干杯

彼得

Here you have some useful tips about using JToolbar on the frontend http://docs.joomla.org/How_to_use_the_JToolBar_class_in_the_frontend

I have done it once in the past, and from what I remember I did some tricks in order to make it work.

1.) Firstly remove the "id" input and add the following one at the end of your form:

<input type="hidden" name="boxchecked" value="0" />

2.) Secondly make sure Mootools is attached to the source

3.) Finally: There, where you started your foreach loop, after "tr" tag add another table column:

 <td><?php echo JHTML::_('grid.id', $i, $item->id ); ?></td>

Don't forget to create a column heading in thead for this column.

These steps will create a checkbox in the first cell of every row and make the form able to send selected field's id with request.

edit:
tbody tag is in wrong place, it's supposed to be after thead tag. Also there is no use of attaching events to hidden input as they won't be triggered

Cheers

Peter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文