I am using the following code to switch to a custom theme based on the URL
function job_agent_custom_theme() {
if (arg(0) == 'vista') {
return 'vista';
}
}
This works great and will switch to my "vista" theme when "vista" is in the URL. The problem is that one of my pages has a form that is submitted via AJAX. I created the form using the standard Drupal form API and creating my submit button like so
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#attributes' => array('class' => array('submit')),
'#ajax' => array(
'callback' => '_display_form',
'wrapper' => 'ajax_wrapper',
'effect' => 'fade',
'event' => 'click',
),
);
So the problem is that when I submit the AJAX form, the page switches to this weird hybrid of the default theme and my custom theme. It's like they are both loaded. Am I missing something? How do I preserve the custom theme when submitting an AJAX form. It also seems really weird to me that the entire page would refresh and switch to a different theme anyway. I would think that defeats the whole purpose of AJAX. I can understand the contents of my ajax_wrapper changing, but not the entire page. Anyway, does anyone know of a way to preserve my theme when submitting via AJAX?
EDIT: Oh and I forgot a big piece to this puzzle. This ONLY happens with anonymous users. If I am logged in, it works as expected and when submitting the form, the custom theme is preserved, but if I am NOT logged in I get the mish mash theme.
THANKS
drupal_set_message('Hello world');
on the page somewhere (and then clear caches) to see if some initial caching is somehow causing this (pages with messages aren't cached and this seems a quick way to see if this is an issue)