Page 1 of 1

How to force reload of a DIV or SPAN?

Posted: 04 January 2021, 04:50
by GoDodyGo
In my JS code, I change part of a "stock" datastructure (playing cards face up on a table) and then want to have the browser redraw it. I do the update to the stock data element, but the screen won't redraw until I resize the window (or reload the whole page, which is too slow).

So, from JS, how can I get the browser to reanalyze this stock element?

For example, I use this STOCK element (pseudo-code):

Code: Select all

this.downArea[player_id].addToStockWithId(...yadadaya... proper stuff...) // This is set up properly
Next, I have a function which manipulates the .items portion of it. So this:

Code: Select all

items: Array(4)
0: {id: "30", type: 13}
1: {id: "29", type: 15}
2: {id: "69", type: 16}
3: {id: "161", type: 52}
length: 4
__proto__: Array(0)
becomes this (two items have swapped indices):

Code: Select all

items: Array(4)
0: {id: "30", type: 13}
1: {id: "161", type: 52}
2: {id: "29", type: 15}
3: {id: "69", type: 16}
length: 4
__proto__: Array(0)
But: The display won't update automatically when the stock item is changed. However, if I resize the browser window, even just a few pixels, then all the cards jump to their proper places (great!). But then if a player adds stock items to ones on the board, they jump around how I don't want them to be (bad!).

I tried things like this (and several similar which I found online) but it errors "Cannot read property 'load' of null"

Code: Select all

$("#downArea").load(" #downArea > *");
Any ideas?

Re: How to force reload of a DIV or SPAN?

Posted: 04 January 2021, 11:09
by tchobello
hi

have you tried anything like this ?

Code: Select all

this.mahjongValues.updateDisplay();

Re: How to force reload of a DIV or SPAN?

Posted: 05 January 2021, 03:49
by GoDodyGo
Oh wow it worked! I didn't see that function before. That's what I needed thank you so much!!