I don't think this is trivial by any means. It is a consequence of the following result:
If $X$ is a scheme with $f_1,\ldots,f_n\in\mathscr{O}_X(X)$ which generate the unit ideal and each $X_{f_i}$ is affine, then $X$ is affine.
Here, for a scheme $X$ and a global section $f\in\mathscr{O}_X(X)$, $X_f=\{x\in X:f_x\notin\mathfrak{m}_x\}$ is the open set where $f$ ``doesn't vanish." If $X=\mathrm{Spec}(B)$ is an affine scheme, then $X_f=D(f)$ is the standard open associated to $f$.
First I'll assume the result and explain why it implies the result you're interested in. Say $X=\mathrm{Spec}(B)$ and $Y=\mathrm{Spec}(A)$, and let $\varphi:X\rightarrow Y$ be the morphism corresponding to the ring map $\varphi^\sharp:A\rightarrow B$. Let $V$ be an affine open of $\mathrm{Spec}(A)$. Write $V=\bigcup_{i=1}^n D(f_i)$ for $f_i\in A$. Then $\varphi^{-1}(V)=\bigcup_{i=1}^n \varphi^{-1}(D(f_i))=\bigcup_{i=1}^n D(\varphi^\sharp(f_i))$ is an affine open cover of $\varphi^{-1}(V)$. The global sections $f_i\vert_V\in\mathscr{O}_Y(V)$ generate the unit ideal (because $V$ is covered by the $D(f_i)=D(f_i\vert_V)$), so their images under $\varphi^\sharp$ generate the unit ideal in $\mathscr{O}_X(\varphi^{-1}(V))$. Since $D(\varphi^\sharp(f_i))=\varphi^{-1}(V)_{\varphi^\sharp(f_i)\vert_{\varphi^{-1}(V)}}$ is affine for each $i$, the result above implies that $\varphi^{-1}(V)$ is affine.
Now I'll sketch the proof of the result. There is a unique morphism $\varphi:X\rightarrow\mathrm{Spec}(\mathscr{O}_X(X))$ which induces the identity on global sections (for any scheme $X$ and even any locally ringed space). This morphism is an isomorphism if and only if $X$ is an affine scheme. The inverse image of $D(f)$ for any $f\in\mathscr{O}_X(X)$ under this morphism is $X_f\subseteq X$. The hypothesis on $X$ implies that it is quasi-compact and separated, meaning it is covered by finitely many affine opens (the $X_{f_i}$) whose intersections are also affine ($X_{f_i}\cap X_{f_j}=X_{f_if_j}$ is a standard open of each of $X_{f_i}$, $X_{f_j}$). This implies (Exercise 2.16 in Hartshorne, I think also proved in Liu) that the natural map $\mathscr{O}_X(X)_{f_i}\rightarrow\mathscr{O}_X(X_{f_i})$ is an isomorphism of rings. Now the assumption that $X_{f_i}$ is affine implies that the restriction of the natural map $\varphi$ to $X_{f_i}$ induces an isomorphism $X_{f_i}\cong D(f_i)$. This is because the map on global sections of the morphism $X_{f_i}\rightarrow D(f_i)$ is, by construction of the map $\varphi$, the natural map $\mathscr{O}_{\mathrm{Spec}(\mathscr{O}_X(X))}(D(f_i))=\mathscr{O}_X(X)_{f_i}\rightarrow\mathscr{O}_X(X_{f_i})$, which I've said is an isomorphism, and a morphism of affine schemes which induces an isomorphism on global sections is an isomorphism. Since the $D(f_i)$ cover $\mathrm{Spec}(\mathscr{O}_X(X))$, as follows from the assumption that the $f_i$ generate the unit ideal, this implies that $\varphi$ is an isomorphism, so $X$ is affine.
EDIT: Jeff Tolliver's comment shows that my argument is overkill for this particular statement; however, my argument can be used to show that for a morphism of schemes $f:X\rightarrow Y$, if there is an affine open cover $Y=\bigcup_i V_i$ such that $f^{-1}(V_i)$ is affine for all $i$, then $f^{-1}(V)$ is affine for any affine open $V$ of $Y$.