Tunneling dynamics of bosonic Josephson junctions assisted by a cavity field