0

So this is somewhat common issue and the issue is I have a Joomla website with K2 extension and running the JAWall template. My problem is when a user wants to post an item in the frontend of my website and hits save the lightbox that pops up does not close. The post is added and there is some kind of update but the box stays.

I have found a few forums that discuss the issue and a Google code bug report here and again in the K2 forums here and again on the Joomla forums but none of them have a solution that works for my situation. I can add a

window.parent.location.reload()

And this will work but it will not wait if the user is uploading some media in their post. So how can I make this function wait for the upload? The code I am trying to add this to is long but the main chunk is at the top so I'll post that here to hopefully help someone understand the situation better.

<?php


// no direct access
defined('_JEXEC') or die('Restricted access');

$document = & JFactory::getDocument();
$document->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton){
    if (pressbutton == 'cancel') {
        submitform( pressbutton );
        return;
    }
    if (\$K2.trim(\$K2('#title').val()) == '') {
        alert( '".JText::_('K2_ITEM_MUST_HAVE_A_TITLE', true)."' );
    }
    else if (\$K2.trim(\$K2('#catid').val()) == '0') {
        alert( '".JText::_('K2_PLEASE_SELECT_A_CATEGORY', true)."' );
    }
    else {
        syncExtraFieldsEditor();
        \$K2('#selectedTags option').attr('selected', 'selected');
        submitform( pressbutton );
        //window.parent.location.reload();//this is what i added            
    }
}
");

?>



<form action="index.php" enctype="multipart/form-data" method="post"
 name="adminForm"    id="adminForm">
<?php if($this->mainframe->isSite()): ?>
<div id="k2FrontendContainer">
    <div id="k2Frontend">

        <table class="k2FrontendToolbar" cellpadding="2" cellspacing="4">
            <tr>

                <td id="toolbar-save" class="button">
                    <a class="toolbar" href="#" onclick="javascript: submitbutton('save'); return false;"> <span title="<?php echo JText::_('K2_SAVE'); ?>" class="icon-32-save"></span><?php echo JText::_('K2_SAVE'); ?> </a>
                </td>
                <td id="toolbar-cancel" class="button">
                    <a class="toolbar" href="#" > <span title="<?php echo JText::_('K2_CANCEL'); ?>" class="icon-32-cancel"></span> <?php echo JText::_('K2_CLOSE'); ?> </a>
                </td>
            </tr>
        </table>

If anyone has an idea to point me in the right direction I would appreciate it I'm here at work on a Saturday because of this issue!

Shaz
  • 2,647
  • 2
  • 35
  • 45
Courtland
  • 5
  • 1
  • 5

1 Answers1

0

My work switched to EasyBlog thanks to K2 issues like this. The issue seems to be in the submitForm() function. There's probably a $app->setRedirect() that isn't redirecting.

window.parent.location.reload() is superflous. If you just want to refresh the page, all you need to do is remove the return false; in the form's onclick.

SomeKittens
  • 38,868
  • 19
  • 114
  • 143
  • Is the single \ intentional, or did you mean to fully comment out that line? – SomeKittens Aug 12 '12 at 01:27
  • I appreciate the quick response and I also notices some code left in there that was from testing the only line I added was the window.parent.location.reload(); after the last else, I have modified it to look right, eveything else is from K2 – Courtland Aug 12 '12 at 01:30
  • @Courtland Fixed my answer. The \ is syntax I'm unaware of. – SomeKittens Aug 12 '12 at 01:34
  • Ah, ok. Have you checked `submitForm()`? – SomeKittens Aug 12 '12 at 01:49
  • When I do a notepad++ search of the site for "submitForm" I get 156 hits in 85 files and none of them look to be incomplete or anything like that, but my skill level is beginner at best. Whether or not I fix this I appreciate your time in this issue. – Courtland Aug 12 '12 at 02:25