Two decks collapsed on a three-story building in Wildwood on Saturday, injuring at least 22 people in a pile of wreckage on the next-to-last weekend of summer.

Twenty-one people were taken to Cape Regional Medical Center in Cape May Court House, one of whom was then flown to a trauma center by air ambulance, hospital spokesperson Susan Staeger said. Another person with serious injuries was awaiting transfer to another hospital by ground, she said.

One person was treated for injuries at AtlantiCare Regional Medical Center in nearby Atlantic City, officials said.

Onlookers posted dramatic photos on social media, depicting dozens of firefighters and police in the process of extricating people from the fallen structure.

The house is in the 200 block of East Baker Avenue, a block from Wildwood High School and two blocks from the boardwalk.

The collapse was reported shortly after 6 p.m.

Eleven of the 21 people who were taken to Cape Regional were treated and released, Staeger said. Two of those who were released were children.

The Shore town was full of firefighters attending the New Jersey Firemen’s Convention. Among the victims were at least six firefighters and family members from the Branchville, N.J. fire department in Sussex County, according to the county fire chiefs association.

“None of those injuries appear to be life threatening," the association wrote in a Facebook post. “They were on the second floor deck when the top floor deck collapsed.”

Staff writer Amy S. Rosenberg contributed to this article.