In March, after wooing House conservatives on an Obamacare repeal deal blew up in his face, President Trump openly flirted with working with Democrats. And Democrats openly rebuffed him.

They complained that since getting inaugurated, Trump had taken a hard turn to the right and hadn't called them to ask their insight on anything. Why should they suddenly work with him if he didn't want to work with them?

“If he changes,” Senate Minority Leader Charles E. Schumer (D-N.Y.) told ABC at the time, “he could have a different presidency.”

This week, suddenly, Trump did appear to change. He invited Democrats to meet with him, alongside Republicans, at the White House to discuss how Congress should attack a debt ceiling, government shutdown and hurricane aid bill deadline. He listened to them. Then, he sided with them, right in front of Republicans' faces.

And the deals came.

On Thursday, Trump talked with House Minority Leader Nancy Pelosi (D-Calif.) and Schumer by phone. Pelosi said she asked him to tweet assurance to “dreamers” that they won't be deported in this six-month limbo period. And he did.

“[I said] I'm going to ask the president to do [this] and — boom, boom, the tweet appeared, so that was good,” Pelosi told reporters Thursday.

Also on Thursday, The Washington Post's Damian Paletta and Ashley Parker reported that Trump and congressional Democratic leaders have struck a “gentleman's agreement” to try to permanently remove the requirement that Congress raise the debt ceiling whenever the Treasury Department runs out of money.

The news follows another deal Trump cut Wednesday with “Chuck and Nancy,” as he casually referred to the Senate and House minority leaders, to raise the debt ceiling only for three months, as opposed to Republicans' request to do it for 18 months. About an hour earlier, Ryan had called a three-month debt-limit hike “ridiculous.”

This is a total 180 from the first seven months of Trump's presidency. Wednesday's Oval Office meeting with congressional leaders was the first substantial policy meeting to which the president has welcomed Democrats. And they left that meeting with everything on their wish-list checked off by the president.

From Democrats' perspective, they're working with a nearly unrecognizable president. But, hey, they'll take it.

Cautiously.

Democratic aides in Congress say they are under no illusion that Trump's sudden change of heart about working with them will last. If the president has proved anything, it's that he has no allegiance to any party in Congress.

“Any Democrat who thinks he can cut a deal with Trump needs to be very, very careful,” said Jim Manley, a Democratic operative and former top aide for then-Senate Minority Leader Harry M. Reid (D-Nev.). “What he agrees to one day could change completely, in 24 hours or less. … He's operating simply on a whim.”

Plus, for all this negotiating, the net result for Democrats is that they get to do more negotiating. By forcing another vote in December on the debt ceiling and budget, Democrats will try to extract concessions from Republicans. But there's no guarantee what those concessions will be, or that they'll get any.

Some lower-rung Democratic members of Congress are upset that their leaders haven't used this unsuspecting and probably fleeting moment of the president's attention to secure dreamers' legal status.

The deal to lift the debt ceiling permanently isn't a sure thing, either. Democrats and Trump will have to get it approved by a Republican-controlled Congress. And many of those lawmakers like that Congress has control over the Treasury Department's ability to issue debts to investors so that it can borrow money to pay its bills. Congress controls the government's purse strings, after all. And in recent years, hesitating to give the government the ability to borrow more money has become a way for fiscally conservative Republicans to flex their fiscally conservative muscles.

But from an image standpoint, even the appearance of striking a deal with the president to get rid of the debt ceiling is a win for Democrats. They get to pass themselves off as the grown-ups, the ones who won't play politics with the debt ceiling.

Trump is still radioactive among the Democrats' base, but polls suggest striking deals with him is a popular strategy. A March CNN-ORC poll found that 72 percent of the public thought Trump should try to reach bipartisan compromise, including 57 percent of Republicans.

Way back in March, when Trump and the Democrats' relationship was at a nadir, Democrats asked for this — a president who listens to them and welcomes their ideas and makes deals with them. They didn't really expect to get it. And they'll take it for as long as it lasts.