I'm going to cite quote from Peter Neumann. He is the former director for the International Centre for the Study of Radicalisation. He said that “without grievance, ideology does not resonate”—it doesn't appeal to the mind; it doesn't make sense—“while without ideology, grievances are not acted upon” because here ideology means action-enabling ideas.
One can look at both of those somewhat equally or at least not favouring one over the other. There's a limit to ideology sometimes. For example, when we hear about jihadist groups in the Middle East, if the U.S. were to suddenly pack up and leave, I don't believe, especially for those who believe the U.S. military occupation is a grievance in this regard, that the jihadists would suddenly start playing nicely with everybody, so there's a limit to the grievances.
When it comes to the ideology, again, sometimes ideology is a driver of violent extremism, but at other times, it's just a passenger with other psychosocial factors at the wheel.
It's important for us to look at the multiplicity of factors and not to just try to do that one-size-fits-all attribution.