Supermassive black hole binaries are the most promising source of gravitational-waves in the frequency band accessible to pulsar timing arrays. Most of these binaries will be too distant to detect individually, but together they will form an approximately stochastic background that can be detected by measuring the correlation pattern induced between pairs of pulsars. A small number of nearby and especially massive systems may stand out from this background and be detected individually. Analyses have previously been developed to search for stochastic signals and isolated signals separately. Here we present BayesHopper, an algorithm capable of jointly searching for both signal components simultaneously using transdimensional Bayesian inference. Our implementation uses the Reversible Jump Markov Chain Monte Carlo method for sampling the relevant parameter space with changing dimensionality. We have tested BayesHopper on various simulated datasets. We find that it gives results consistent with fixed-dimensional methods when tested on data with a stochastic background or data with a single binary. For the full problem of analyzing a dataset with both a background and multiple black hole binaries, we find two kinds of interactions between the binary and background components. First, the background effectively increases the noise level, thus making individual binary signals less significant. Second, weak binary signals can be absorbed by the background model due to the natural parsimony of Bayesian inference. Because of its flexible model structure, we anticipate that BayesHopper will outperform existing approaches when applied to realistic data sets produced from population synthesis models.