DataTable render table "columns" executes twice

now there is a demand: the ad space table selects an ad to display this ad space the next time it comes in, and if there is no choice, the first ad space is selected by default, and then this ad space will control the display of the corresponding ad table.
but found in processing:

clipboard.png

the first $("- sharpNE_choose_advPlaceId"). Val () is to save the previously selected advertising space, so as to determine whether to reflect the previously selected advertising space, and the second is to determine whether it is the first time to enter (that is, whether it has been selected) to satisfy that one of them has entered.
but later found that the code will first enter the if according to onceadvPlace, and then set the value of $("- sharpNE_choose_advPlaceId") as the first ad bit, and immediately enter it again because full.id = = $("- sharpNE_choose_advPlaceId"). Val ()), that is, the code in if will be executed twice. How to avoid executing twice? Ask the great god for advice.

Mar.08,2021
Menu