joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.74k stars 3.65k forks source link

Joomla.renderMessages - Cannot read property 'joomla.jtext' of null #16217

Closed Wojton closed 7 years ago

Wojton commented 7 years ago

Steps to reproduce the issue

  var messages = { "message": ["Message one", "Message two"],
                            "error": ["Error one", "Error two"]
                        };
 Joomla.renderMessages(messages);

   jQuery.ajax({
                    url: "index.php",
                    type: "POST",
                    data:
                    { 
                        option: "<?php echo $option ?>",
                        task: "messageform.sentMessage",
                        params: "<?php echo $this->params64 ?>",
                        "<?php echo JSession::getFormToken() ?>": '1',
                        msg:jQuery("#gs-message").val()
                    },
                    dataType: "JSON",
                    success: function(json){
                        var messages = { "message": ["Message one", "Message two"],
                            "error": ["Error one", "Error two"]
                        };
                        Joomla.renderMessages(messages);
                      //  Joomla.renderMessages(json.messages);

                        if(json.data == "message_send"){
                            jQuery("#ga-jq-submit-message-form").fadeOut('fast',function(){
                                jQuery(this).remove();
                            });
                        }
                    }
                });

Expected result

Correct system message

Actual result

Uncaught TypeError: Cannot read property 'joomla.jtext' of null
    at Object.e.getOptions (core.js?4d4a824…:1)
    at Object._ (core.js?4d4a824…:1)
    at Object.e.renderMessages (core.js?4d4a824…:1)
    at Object.success (messageform.html?tmpl=component&09ca28f…=1&params=YToyOntzOjM6ImFpZCI7czozO…:226)
    at i (jquery.min.js?4d4a824…:2)
    at Object.fireWith [as resolveWith] (jquery.min.js?4d4a824…:2)
    at y (jquery.min.js?4d4a824…:4)
    at XMLHttpRequest.c (jquery.min.js?4d4a824…:4)

System information (as much as possible)

Joomla >3.7 (in joomla <=3.6.5 worked)

dgrammatiko commented 7 years ago

I can't replicate this! Please make sure that core.js is loaded in your view!

screen shot 2017-05-23 at 21 22 50

code I used:

   jQuery.ajax({
                    url: "index.php",
                    type: "POST",
                    data:
                    { 
                    },
                    dataType: "JSON",
                    success: function(json){
                    }, error: function() {
var messages = { "message": ["Message one", "Message two"],
                            "error": ["Error one", "Error two"]
                        };
                        window.Joomla.renderMessages(messages);}
                });
izharaazmi commented 7 years ago

I can confirm this issue exists. And since I had not enough time to dive in, I am using a workaround that is making a useless JText:: script() call in my layouts.

Fedik commented 7 years ago

@Wojton please enable Debug mode, and post here the javascript error again?

tonypartridge commented 7 years ago

Is this not caused by not having the system-messages container rendered?

andrepereiradasilva commented 7 years ago

could this also be related to the progressive cache issue like https://github.com/joomla/joomla-cms/issues/16375#issuecomment-305864460 ?

  1. The JHtml::_('behavior.keepalive'); inside the mod_login template file is not being processed when cache in conservative mode.
Fedik commented 7 years ago

it should be fixed with #16488

ghost commented 7 years ago

@Wojton can you please test #16488 if it fixes this Issue & in so close this Issue – thanks.

andrepereiradasilva commented 7 years ago

https://github.com/joomla/joomla-cms/pull/16488 should resolve the js error

But there is the issue of the joomla.jtext json could not being loaded in certains conditions and that could be the same issue as https://github.com/joomla/joomla-cms/issues/16375#issuecomment-305864460

@Wojton is this used in a module? does this happen with Progressive cache enabled?

ghost commented 7 years ago

If this Issue get no Response, it will be closed at 17th September 2017.

joomla-cms-bot commented 7 years ago

Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/16217

ghost commented 7 years ago

This has been closed due to lack of response to the requests above – it can always be reopened.