Uncaught TypeError: Cannot read property 'addEvent' of null

I've opened up my form to allow users to change their email address which is also their login user name. So for the interim we can ignore the fact that it's an email address, this field value is the one that is synchronized with the joomla jos_users.username value. So basically I'm allowing them to change their login.

When a user logs in, changes this value, submits, logs out and then logs back in immediately, now using their new username, they correctly access the form, no issue with logging in but I get this 'Uncaught TypeError: Cannot read property 'addEvent' of null' (form.js line 2), I lose pagination, previously set button values (ex. radio buttons) no longer show a value and display as though they were never selected. If I reload the page everything goes back to normal.

I've narrowed it down to this block of code in the form.js. Note the object is not null but this.form (line 3) is null and the error is thrown on the line that reads this.form.addEvent("click:relay(.fabrikSubGroup)", function(a, b). I'm no js expert I'm hoping maybe this is something simple that you are aware of, even a workaround, if I could force expire the session cookie on logout maybe that would fix it?

watchGroupButtons: function() {
var b = this;
a(this.form).on("click", ".deleteGroup", d(this.options.debounceDelay, !0, function(a) {
if (a.preventDefault(),
!b.addingOrDeletingGroup) {
b.addingOrDeletingGroup = !0;
var c = a.target.getParent(".fabrikGroup")
, d = a.target.getParent(".fabrikSubGroup");
b.deleteGroup(a, c, d),
b.addingOrDeletingGroup = !1
}
})),
a(this.form).on("click", ".addGroup", d(this.options.debounceDelay, !0, function(a) {
a.preventDefault(),
b.addingOrDeletingGroup || (b.addingOrDeletingGroup = !0,
b.duplicateGroup(a, !0),
b.addingOrDeletingGroup = !1)
})),
this.form.addEvent("click:relay(.fabrikSubGroup)", function(a, b) {
var c = b.getElement(".fabrikGroupRepeater");
c && (b.addEvent("mouseenter", function() {
c.fade(1)
}),
b.addEvent("mouseleave", function() {
c.fade(.2)
}))
}
.bind(this))
},
 
I'd have to see the page, and be able to replicate the error so I can debug it. Not something I've ever seen.

So I'll need to know which site, and have a login on it I can test with.

-- hugh
 
Use the second site in my list with the dev account. Note the username is an email address:
1. login
2. change the email address
3. save
4. logout
5. log back in and note the js error
6. refresh and it's gone
Let me know if you need any additional information
 
I don't seem to have admin access.

Can you set Debug to "JS" in the global Fabrik options? I'll need the uncompressed JS when I log back in first time, won't get the second bite I'd need to append fabrikdebug=1 to the redirected URL.

-- hugh
 
Hmmm. The problem seems to be that even though it's rendering it as a form view, the "block" (the form object in Javascript) is being created as a details view. So at the point we build the JS during the view processing on the server side, there's a hiccup in the permissions, and something like canEdit() is returning false ... but later on in the page rendering, it's returning true.

It's possible I might be able to debug this, but it'll be a pain in the butt. This kind of session issue is just nasty in J!. It'll be something deep in the guts, to do with changing a login.

My suggestion is that you don't redirect directly to this form after logging in, so there's another page load between logging in with the new username and displaying the form, to allow J! time to unbundle its panties.

-- hugh
 
I just did some more testing and it turns out it's not related to the username update. If I remove the ability to update your username, simply log in, save, log out and then log in again I get the same js error.
Now where I can't do anything about redirecting to another page, can you think of an easy way to expire the session cookie when the user hits 'logout'? I think that would solve my problem.
 
I just tested my theory and it works. If I delete the cookie reference in the jos_session table when the user logs out, when they try to log in they are prompted that their session has expired and to log in again. So by doing this their failed submit refreshes the page. Once they attempt to log in a second time they get a new session cookie and the form contents load fine.
 
What's weird is I thought the session row should get deleted when the log out.

Sent from my HTC6545LVW using Tapatalk
 
I have a workaround. I have a component I use to handle redirects, so I set it to redirect the user to a hidden redirect script on logout which redirects the user back to the login screen. That in of itself somehow allows joomla to reload the js. Works for me:)
 
It's weird, I can't replicate this. Is that form in a module, or a simple component menu link?

Sent from my HTC6545LVW using Tapatalk
 
Yup, weird. I absolutely cannot replicate this. I log out, login in, and have a form as a component link on my home page, it works fine.

-- hugh
 
Ah, I thought I'd committed my nasty little hack for that a while back. Just committed it. See my response on that thread.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top