Setting Custom Image Background For Your Mobile App
Posted: October 24th, 2011 | Author: max | Filed under: Features | Tags: BlackBerry, JavaScript, jQuery, jQuery Mobile, tips | 9 Comments »A number of users asked us how to use a custom image as background for mobile app. We are working on this feature but a simple work around exists. We want to run a very simple jQuery CSS query when the mobile screen loads. First, add load event to the screen. Then, add Run Custom JavaScript action with the following code:
1 2 | $('div[dsid="mobilecontainer1"]').css('background-image', 'url("http://www.sdcblog.com/wp-content/uploads/2011/06/italy.jpg")') |
I removed the Header and Footer parts and also looking for mobilecontainer1, as this is the content where I want to set the background image.
The result (click image to view the app):
Image source: http://www.sdcblog.com/2011/06/italian-artchitecture-bellissimo/italy/
For some reason when I try to do this it refuses to save the custom javascript.
When happens when you reopen the JavaScript window? The code is not there..?
Yep, the window opens fine and I put javascript inside and click OK. It never saves the information. I can add navigation links and invoke datasets, etc. just no custom javascript gets saved in the on load for the page
@Jeff: I’ll reply to the email that you sent.
Tested and it works.
Better: upload an image as an asset, use the asset URL on gotiggr.com in the javascript. The APK gest generated with the included background.
The only pain is that the background must be added manually on every single page.
@Danbec: You sort of already can do that. Upload an image to your app. Place the image on a screen and run test. Using Firebug (or similar), look at the image src attribute. It will be something like this: http://gotiggr.com/views/assets/asset-xxxxxxx. You can use this URL for the background, or even just /assets/asset-xxxxxxx.
This is useful info and it works in Test from the editor, but when I go and test using Tiggzi Tester, the images do not show up…
I am testing what is suppose to be just an HTML5 app and I have tried both the absolute url and relative /assets/ url and in both cases the images don’t show in the tester app…
Any ideas?
@DavidK: please post the code that you used to set the image on our forum: http://tiggzi.com/forum
Ok, thanks, I posted it over there…