How would I get custom css and custom javascript to load in the live preview?
I'm updating the webcams module to D6 and Views2, and have everything working. Except that the live preview doesn't look like the actual page due to the css and js not loading there.
Any pointers are appreciated.
Comments
Comment #1
merlinofchaos commentedPlugins can add 'js' directives in their definition which will cause that js to be loaded. Fields currently don't have a mechanism, but you can test the path for admin/build/views/edit in hook_init and add your js there, which should be enough.
Comment #2
moonray commentedI can't add the js on init, since it's generated when the field is rendered. It needs to know certain options which are set in the view, and generates the js based on that. Perhaps fields should have js mechanisms?
What about css? Is there a field-specific css mechanism?
All in all, views 2 adds a lot of nice things, and the live preview is very nice. If it doesn't work with live preview, it's not critical, but it would feel more cohesive.
Comment #3
merlinofchaos commentedYou can add settings as with the drupal_add_js() command with the 'settings' via the $view->js_setting variable (it should be an array, just like what you'd pass to drupal_add_js). You'll still need to add any base javascript files in hook_init for now, though I will try to find a way to change that.
Comment #4
mrfelton commentedI'm having trouble getting javascript to load in my views live preview too. Did you get this workin? Care to shed some more light on the subject? Currently I'm adding my Javascript in hook_views_pre_view() using drupal_add_js, which works fine, except in the live preview where I get no javascript at all.
I did try setting $view->js_settings in hook_views_pre_view() also, and my settings were indeed passed into the live preview (confirmed with dsm()) - but I need to load a javascript file and a css file... How can I getr Views live preview to call in my css and js files:?
Comment #5
domesticat commentedClosed while closing all Views support requests with no activity for 6 months. If you still need help, you may re-open this issue at any time.