MZ Window placement plugin acting up, but only once.

Hi, first time posting in this Plugin support thread.
Trying to make my own HUD plugin that would allow me to move windows arround.
Now this is my very first plugin I am working on, so please bear with me:

Most of the plugin is "remed" as in within /* */ for now, since I am trying to work out an odd thing that happens with the plugin.
It only works as inteneded, the second time I open a "Select Item" window.

I have narrowed the problem down a bit, I think.... but I have no clue how to solve the issue.

The whole point of the plugin will be to allow the user (me in this case) to move the select window item around, controll width/height, and/or show the number of items the user has, aswell as turn off the "back key" as I don't plan for a mobile release, and right mouse botton/cancel does the same thing.
(Once I have added the basic functions, I want to remake the whole thing, adding plugin-calls so the options can be changed on the fly, but for now, I need to get the basics down.)

The first time it runs it doesn't quite work:
temp1.png

Note how the select box isn't quite matching up to the window as well as the number of Super potion/magic water is outside the frame of the window.

However, the second time I call for an "Item select" it works just as intended:
temp2.png


My guess is that I am forgetting to initiate something, or rather, need to initiate something, before the plugin takes effect, but since I am new to all this, I have no clue as to how to do this. (My thought is to, more or less, run the code through once before it is called upon. It should/would fix it, I think...) It is, a bit like it is running the code in the wrong order... setting the size of the window, after it is filled in.

I think I should also note that saving the game, and rerunning it, resets the problem, causing it to once again have the same bug, but only the first time a "select item" event is called. Once it has been called once, the bug goes away on its own.

Any suggestion would be most welcomed as I have been trying to figure this one out for about 3-4 days nows and not being able to find a way to solve it on my own. (Probably over looked something super obvious....)

For those that don't want to see the horrible mess that is my js file, here is basically the important stuff:

Window_EventItem.prototype.updatePlacement = function() {
this.width = 864; //Width in px, later to be made into a plugin-parametre
this.height = 192; //Height in px, later to be made into a plugin-parametre
this.x = ((Graphics.boxWidth - this.width) / 2); //X-position, later to be made into a plugin-parametre
this.y = (Graphics.boxHeight - (this.height*2)); //Y-position, later to be made into a plugin-parametre
};

As you can see, nothing really strange here... At least, I don't think there is, yet it somehow makes rpgm, mess up the initiation... I think..? Maybe...
Please help.
Moved to Learning JavaScript. This is the best board by far for getting help with writing code; Plugin support is more for getting help using an existing plugin correctly.

Windows are not my forte, but my instinct is that you may need to set the same values (or even just call the updatePlacement() method) as soon as your instance of Window_EventItem is created. I'm hoping someone can provide more specific direction than this!
We live and learn...
Thank you for moving it to the right place, now I just hope someone can help me out with figuring out how to fix this...
You need to include the following lines after you edit the window's width/height in order to recreate, then redraw, the contents:
JavaScript:
this.createContents();
this.refresh();
thank you I will test it out!

Edit:Tested and worked! Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/window-placement-plugin-acting-up-but-only-once.131163/