Titanium Button image does not show up - button

I need to add a background image to a button in Titanium studio (version 3.1.1). I tried almost everything I can think of but still the button image does not show up. Image file path is correct. I cleaned the project, restarted titanium still not working. I had the same problem when I was trying to add window background image, it didn't show up and suddenly it appeared without even changing a line of code. How can I fix this?
var pauseResumeButton = Titanium.UI.createButton({
title:"play",
top:'70%',
width:80,
height:80,
backgroundColor:'green',
backgroundImage:"/graphics/play.png",
});

Try the following code
var pauseResumeButton = Titanium.UI.createButton({
title:"play",
top:'70%',
width:80,
height:80,
backgroundColor:'green',
backgroundImage:"graphics/play.png",
});
Also please refer this answer

Try to change your button's background to transparent like that:
var pauseResumeButton = Titanium.UI.createButton({
title:"play",
top:'70%',
width:80,
height:80,
backgroundColor:'transparent',
backgroundImage:"graphics/play.png",
})
win.add( pauseResumeButton )

Related

Img tag is not displaying the image

It's my first time to have this kind of problem. As you can see on the IMG tag, the image is not visible. I'm not sure what can cause this problem. When I copy the link and insert it in a new tab, the image is there. I tried to add a new class and define width/height but didn't fix the problem
#foreach (var theimg in Model.AdExtraImages)
{
<img src="~/adimages/#theimg.AdId/#theimg.Image" class="the-extra-image"/>
}
URL(copy/paste new tab, where the image is ok):
https://localhost:44374/ads/4/adimages/1015/0f25eed4-1413-4854-96a7-6cdfb2300d9e_esresr.jpg
Problem solved I disabled adblocker
If you want to see your image with enable adblocker,
Rename your ads and adimages to other names that do not include ads, advertisements, etc.

Simple JavaScript not working when changing color in the body

when watching this tutorial, I tried to repro the JavaScript used in the beginning.
However when setting up the function
function setRandomColor(e)
{
var bodyElement = document.querySelector("body");
bodyElement.style.background.Color = "yellow";
}
the part
bodyElement.style.background.Color = "yellow";
does not run, simply because style is not shown as an option.
Per my reseach this is supposed to work. Therefore my question: Is this a bug or what?
Note that I am using Visual Studio 2015 with Apache Cordova, version 14.0.22609.0 (CTP6, I believe).
Thanks
You should use
bodyElement.style.backgroundColor
According to w3schools, the background attribute you are calling is not supported in HTML5.
To correctly call the background color, try:
bodyElement.style.backgroundColor = "yellow";
For more information:w3schools explanation

How to convert this to onClick vs regular hover?

Here is a Fiddle, to show my current state: (attempting onClick())
http://jsfiddle.net/D5N4f/7/
$('.associationLinks').click(function () {
alert("I've been clicked"); //test to see if click is working
//$(this).next().toggle();
$(this.content).toggle();
//$(this .content').css("display", "block");
});
here is a version of the working HOVER, that I need to convert to onClick:
http://jsfiddle.net/D5N4f/6/
This is working fine.. however.. on HOVER is just not practical for my use.. I need to change it to onClick..but have the same behavior.
Do I need to use jQuery for this? (I havent been able to get it to work)
the content I want displayed starts off as display:none..
I have tried to show(), toggle() and even .css("display", "block"); (maybe Im not targeting things correctly?)
the last part of this (since there will be MANY links set-up like this) is to close the previous 'SHOW' content.. when I click on a new link.. (ie: only having one content box displayed at a time vs. having several open at same time!)
Please use the fiddle example instead of just random code suggestions! Thanks!
I removed the following CSS:
/*.associationLinks:hover .content {
display:block;
}*/
I also use a .children() selector to get the content div to display, and I change it's CSS on a click.
Is this closer to what you want? Hiding the image is a bit tricker, and I have an idea for that but I'm not sure if you need it.

Button links on Wordpress front page are not clickable

I was given a Wordpress theme to install for a new website and then asked to make some customizations.
The site is here: http://centergrovepto.org/townsend/ (I'm not sure where the original theme came from.)
There are 3 buttons along the right side of the front page slider. "Employers", "Candidates", and "Open Positions". The buttons were initially clickable and all they did was change the current slider image.
I'm trying to make them clickable so that they open the corresponding page. If you hover over each button you can see in the status bar that the link paths are setup correctly, but when I click the button nothing happens.
I'm guessing it is a CSS issue and some layer is covering up the actual buttons, but I don't know enough CSS to figure out what the cause is. I have the Firebug plugin for Firefox installed so I can more easily inspect the CSS. I've played around with changing the z-index of various elements, but I just can't get it to work.
I actually think it's your jQuery Faded plugin. It looks as if this:
if (o.pagination) {
if (o.autopagination) {
$t.append("<ul class="+o.pagination+"></ul>");
$c.children().each(function(){
$("."+o.pagination+"",$t).append("<li><a rel="+number+" href=\"#\" >"+(number+1)+"</a></li>");
number++;
});
}
$("."+o.pagination+" li a:eq(0)",$t).parent().addClass("current");
$("."+o.pagination+" li a",$t).click(function(){
current = $("."+o.pagination+" li.current a",$t).attr("rel");
clicked = $(this).attr("rel");
if (current != clicked) {animate("pagination",clicked,current);}
if(o.autoplay){pause();}
return false; //THIS LINE PREVENTS DEFAULT ACTION WHEN <a> LINK IS CLICKED
});
}
Is preventing the default action of your links. I'm not sure what will happen, but try commenting the "return false" line out. See if any unwanted side-effects happen. Otherwise, add this code to your (or what I assume is yours) custom.js file:
jQuery(".pagination ul li a").click(function()
{
window.location = this.href; //UPDATED FOR EPHRAIM
});
I'm not exactly sure why this is happining, because if you open the link in a new tab, it works perfectly. It's possible that it's a css problem, but more likely, it has to do with your HTML.
What I would try is adding a target to your link. This will tell it to open the link specifically in the window your in, which may solve the problem. (I haven't tested it myself though)
Instead of
Try changing it to one of the following:
Or, if that one doesn't work, try this one as well
Let me know if that helps!
as I've seen on your site, the 3 buttons are linked like this:
a href="/townsend/employers/"
But i think it should be like this to work because a href="/townsend/employers/" does not refer to anywhere in your server
try changing it like so:
<a href="http://centergrovepto.org/townsend/employers/">

How to add background-image to a div?

I am working with the Mojo SDK and I'am trying to add a background image to a div but havn't been able to find a way to do it.
Obviously I have tried doing it the normal CSS-way but it doesn't seem to work with Mojo.
Here is the latest thing I tried:
var t=document.getElementById("kblayoutdiv");
t.parentNode.removeChild(t);
var t=document.getElementsByTagName("BODY")[0];
var div=document.createElement("div");
div.style.position="fixed";
div.id="kblayoutdiv";
div.style.display="block";
div.style.top="80%";
div.style.left="92%";
div.style.width="16px";
div.style.height = "11px";
div.style.background = url('/usr/palm/frameworks/mojo/keyb_en-us.png');
div.style.zIndex = "255";
t.appendChild(div);
window.kblayout="en";
I have tried several solutions to get the background image to show.
The rest is working fine. It is just the background iamge that won't show no matter what.
So if anyone can show me the piece of code to add the background image I'd be real happy :)
div.style.background = url('/usr/palm/frameworks/mojo/keyb_en-us.png');
You have to quote strings in JavaScript
div.style.background = "url('/usr/palm/frameworks/mojo/keyb_en-us.png')";
Obviously, the URI has to be correct as well.
That said, as a rule of thumb, it is almost always better to predefine all your styles in an external stylesheet and generate elements that match the selectors (e.g. by setting .className).

Resources