Joomla 3.0 Component JS error in backend
-
13-07-2021 - |
Domanda
I am developing a Joomla 3.0 component. As sample I downloaded the com_hello component from the Joomla documentation.
The error I am occurring is that when I am checking the checkbox in the list of a view, I get an error message TypeError: b is null
. This error occurred somewhere in the core.js.
Normally in 2.5, if I used the JHtml::_('grid.id',$i,$item->id);
code and had <input type="hidden" name="boxchecked" value="0" />
field in my form it worked fine.
I also looked in some components of the Joomla core, but I didn't find something that was missing or some other error.
Here is the code of the default.php
of my view:
<?php
// NO DIRECT ACCESS TO THIS FILE
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
?>
<form action="<?php echo JRoute::_('index.php?option=com_simplesuite'); ?>" method="post" name="adminForm">
<table class="adminlist">
<thead>
<tr>
<th>ID</th>
<th><input type="checkbox" name="checkall-toggle" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" value="" onclick="Joomla.checkAll(this);" /></th>
<th><?php echo JText::_('COM_SIMPLESUITE_TAGCLOUD_ADMINISTRATOR_LIST_NAME'); ?></th>
<th><?php echo JText::_('COM_SIMPLESUITE_TAGCLOUD_ADMINISTRATOR_LIST_TAGS'); ?></th>
<th><?php echo JText::_('COM_SIMPLESUITE_TAGCLOUD_ADMINISTRATOR_LIST_ACTIONS'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<tr class="row<?php echo $i%2; ?>">
<td><?php echo $item->id; ?></td>
<td><?php echo JHtml::_('grid.id',$i,$item->id); ?></td>
<td><?php echo $item->name; ?></td>
<td><?php echo ($item->tags) ? $item->tags : JText::_('COM_SIMPLESUITE_TAGCLOUD_ADMINISTRATOR_LIST_EMPTY'); ?></td>
<td><a href="#">W</a><a href="#">X</a></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<td colspan="4"><?php echo $this->pagination->getListFooter(); ?></td>
</tr>
</tfoot>
</table>
<div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
Soluzione
Try adding this to the top of your script:
window.addEvent('domready', function () {
if (typeof jQuery != 'undefined' && typeof MooTools != 'undefined') {
Element.implement({
slide:function (how, mode) {
return this;
}
});
}
});
That's probably the mootols conflict that is being under resolution with the dev team.
Altri suggerimenti
For your <form>
element, ensure you have id="adminForm"
also. See http://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_3.0_and_Joomla_Platform_12.1#JavaScript for more info.
Try to use this:
<?php echo JHtml::_('grid.checkall'); ?>
instead of this:
<input type="checkbox" name="checkall-toggle" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" value="" onclick="Joomla.checkAll(this);" />
That worked for me.
Add id="adminForm" into form. I spend a while to find it, had the same problem.
Forms that have name="adminForm" now also require id="adminForm".
see:
I added the following field and it worked for me
<input type="hidden" name="boxchecked" value="" />