TypeError: $w(...).maximize is not a function

Hi, all of a sudden I just started getting such errors for all my functions in JS.

Only change that happened was I removed a chat window object from site and create a new one with same name.

Can someone please guide me on this?

Thanks.

Your issue, make sure that the element that you are using for this does actually support maximize.

Like the Wix Chatbox which supports maximize.
https://www.wix.com/corvid/reference/$w.Chatbox.html#maximize

$w("#myChatbox").maximize();

Hi GOS, it is my bad that i havent mentioned that the code and error was infact belonging to a chatbox object. Any further guesses why this is happening?
Thanks.

No blame us both as you had put in your original post that it was a chat box :wink:

https://www.wix.com/corvid/reference/$w.Chatbox.html

Anyways, the Chatbox does support maximize so please ignore the error and test it on your site in preview and live mode and see if it works.

I think that there might have been a few teething problems with it when it was first launched and I think that this was one of them and it was working in the live site.

if I remember rightly too there was a forum post about this too, which is out there somewhere if somebody can find it!

I will pass this onto Wix team to see if they can get it resolved asap.

Here we go, towards the bottom of this post see the replies from Erez.
https://www.wix.com/corvid/forum/community-discussion/open-chat-widget-when-button-is-clicked

And also these too.
https://www.wix.com/corvid/forum/community-discussion/bug-chatbox-maximize-function-bug
https://www.wix.com/corvid/forum/community-discussion/how-to-access-wix-chat-chatbox-api-events

preview error is not displayed under live, but when I click to the button I dont even see any action which was supposed to maximize the chat baloon.

Just fyi, I am getting almost same error from focusChannel too.

TypeError: $w(…).focusChannel is not a function

By chance, I came across to a similar issue faced in the past and seems to be fixed by Wix admin. My this be a similar case?

https://www.wix.com/corvid/forum/community-discussion/typeerror-onclick-is-not-a-function

Okay I have just checked the Wix Chat example as here and there is no error shown in the code in the Wix Editor.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-corvid-chat/p-1/dl-5e1b2dc807c1a200179327fa

Live site test.
https://www.wix.com/code-examples/corvid-chat
If you click on the Questions? Chat with us… button it all works fine and the Wix Chat app opens as it should.

Please check your code setup for when you use the maximize option as if you have hidden the Wix Chatbox it needs to be set to show first and then maximize, like as in the example linked above.

See here on this test site.
https://givemeawhisky.wixsite.com/test/blank

$w.onReady(function () {
});

export function button1_click(event) {
$w('#wixChat1').hide()
}

export function button2_click(event) {
	$w('#wixChat1').show()
	$w('#wixChat1').maximize();
}

Just to note that if you use mazimize, then that will only work when the Wix Chatbox is set to minimize.

It will not work when it is hidden, then you will need it to be shown first.

As for the focusChannel option, are you using Business or Social as you need to set it up appropriately as Type only works for Business,

Plus, as shown above, it needs to be in the minimize option and if your Chatbox is hidden it needs to be shown.

You can focus on a channel by specifying one of the following:

  • Channel ID: Focus on the channel with the specified ID. type is ignored.

  • Type: Focus on the channel of the specified type. Currently, only type Business is supported.

Examples
Expand the chatbox and focus it on the channel with the specified ID

let channelInfo = {
  "channelId": "23b345b6-c78d-9012-e3f4-567g89h0i01k"
}

$w("#myChatbox").focusChannel(channelInfo)
  .then(() => {
    console.log("Done maximizing chatbox and focusing channel");
  })
  .catch((err) => {
    console.log(err);
  });

Expand the chatbox and focus it on the business channel

let channelInfo = {
  "type": "Business"
}

$w("#myChatbox").focusChannel(channelInfo)
  .then(() => {
    console.log("Done maximizing chatbox and focusing channel");
  })
  .catch((err) => {
    console.log(err);
  });

Hi GOS, unfortenatelly focuschannel() does not maximize the chat baloon and show the previous chat with that channelID. Just fyi, as channelID I have used the username of the previous chat.

You may see the exact code as below;

export function button1_click(event) {
let isGlobal = $w(“#wixChat2”).global; // true
let isHidden = $w(“#wixChat2”).hidden; // false
let myId = $w(“#repeater1”).id; // “myElement”
let isMaximized = $w(“#wixChat2”).maximized; // false
let options = {
“suppressAuth”: true ,
“suppressHooks”: true
}
let channelInfo = {
“channelId”: “92f7ac00-04c5-4ef4-aac2-01499873bcd0”
}
$w(“#wixChat2”).focusChannel(channelInfo)
.then(() => {
console.log(“Done maximizing chatbox and focusing channel”);
})
. catch ((err) => {
console.log(err);
});

That won’t work as Wix Data Options can only be run in the backend.
https://www.wix.com/corvid/reference/wix-data.html#WixDataOptions

The options parameter can only be used in backend code. Permission checks and hooks always run for wix-data functions called from Page, Site and Public code.

Also, note as mentioned above, the maixmize function will only work if the Wix Chatbox is shown on your page whether in the minimized state or already maximized.

If it is already hidden from the page, then you will need to have it shown first before it can be maximized.

Finally, make sure that your channel id is correct type too, are you using social with site member to site member?

Or are you trying to use social on business with site member or visitor chatting with site owner/admin/contributor?.

Site visitors can participate in the following chat scenarios:

  • Business Chat: Site members and visitors chat with the site owner or contributor, referred to as the “business.”

  • Social Chat: Site members chat with other site members, privately or in a group chat.

Hi GOS, the maximize() function works fine, only issue is that when it gets maximized it lists all the users the user had chat previously. Instead i specifically want to show the previous chat with a specific user. And yes I understand this is only available with a social chat not business that is why I pass the userId of specific previous chat.

Still not clear what is wrong on above code. Would you have a sample code that maximizes the chat window with a specific userId?

Thanks.