views:

54

answers:

2

Hi all,

I am using the following code(no my own code) to load image to a css element (called cell) and to display an activity indicator.

var cell = document.createElement('li');
cell.textContent = this.labelForIndex(index);
var indicator = new NKActivityIndicator(); 
indicator.init(10,100,20,"white");
indicator.show(); 
indicator.spin();
$(cell).css("background-image", "url("+iconImage+")"); 

Now i want to place the indicator in the middle of the cell.this line of code indicator.init(10,100,20,"white");define the position width and color of indicator. I want to place it int the mid of cell.Any kind to response?

+1  A: 

You can use jQuery's .position() or .offset() to retrieve the position of the cell and with the use of .height() and .width(), you can place the component in the middle of the cell.

Marimuthu Madasamy
but problem....when i use $(cell).width() i get 0 value???
Rony
It seems in the code you have just created the element. Did you attach the element to DOM?
Marimuthu Madasamy
hi...how to attach it...?
Rony
If you have some UL element with id "container", you can use $("#container").append(cell)
Marimuthu Madasamy
+1  A: 

like all our talk in the comments:

all you need is $(cell).width() and $(cell).height()

and not .position() or .offset() , not this time...

guy schaller
use Code Sample
jjj
but problem....when i use $(cell).width() i get 0 value???
Rony
use firebug for firefox to go over the element and see its width.maybe its not in the right float.maybe you need to give it some css like:display:block; float:left; position relative (if the element inside of it is positioned absolutly)
guy schaller
Hi,.ad-carousel-view .cells > li { width: 200px; height: 70px; padding-top: 16px; padding-left: 20px; color: white; font-size: 20px; font-family: "Helvetica Neue", Helvetica; -webkit-border-radius: 10px; -webkit-box-sizing: border-box; background-color: red; }i think this will set the property...
Rony