I tried to clone an input fields position (adding a border to
highlight it with 4 divs) but IE 7 throws an error telling me, "style
is null or not an object". I found a workaround with using the
cumulativeOffset object.
Here the code:
function highlightElem(element) {
element = $(element);
var cumulativeOffset = element.cumulativeOffset();
var top = $(''highlightTop'');
//top.clonePosition(element, {setWidth: false, setHeight: false,
offsetLeft: -2, offsetTop: -2}); //doesn''t work
top.setStyle( { top: ( cumulativeOffset.top - 2 ) + ''px'',
left:
( cumulativeOffset.left - 2 ) + ''px'', width: (
element.getWidth() +
4 ) + ''px'', height: ''1px'' } );// works
top.show();
[...] // similar for the other 3 borders
}
Any ideas what I am doing wrong here?
ps.
Using the following doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Just browsed through lighthouse, and I am not sure if this is related to the follwoing report: http://prototype.lighthouseapp.com/projects/8886/tickets/9-patch-test-add-element-clonedimensions-fix-cloneposition-viewportoffset-getoffsetparent-and-make-sure-element-getdimensions-works-with-display-none-ancestors If yes, does this mean I have to work with my workaround until 1.6.1 (whenever that is planned to be released) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I think you want this patch: http://dev.rubyonrails.org/ticket/11473 and http://dev.rubyonrails.org/ticket/11472 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi JD Do I see this right, the first patch fixes the clonePosition because it''s relying on the function you fixed? For the second patch, I am not sure if I need it. If I pass a non extended HTML element to my highlightElement function, element wouldn''t have the cumulativeOffset method available anyway. Or do you recomend to call it static where your patch would be needed: Element.cumulativeOffset(element); Cheers Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Thomas. Correct the first patch fixes the style null issue (becuase It returns a valid offsetParent. The second fixes the issue of being able to pass the methods Element.viewportOffset(id) an ID instead of an element (all other methods do element = $(element)) it was just an oversight that needs to be fixed. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi JD
I implemented these patches now, but I still got two different
outcomes in IE7 and FF2.
It is the same as if would use viewportOffset instead of
cumulativeOffset in my workaround. Meaning in this case in IE7 the top
is 1px higher than in FF. Any suggestions? I place these borders
around the input fields on click. Here is the code snippet:
<h2>Form</h2>
<form id="testForm" action="test.html">
<table>
<tr>
<td><label
for="textField">Text:</label></td>
<td><input type="text" id="textField"
/></td>
</tr>
<tr>
<td><label
for="passwordField">Password:</label></td>
<td><input type="password"
id="passwordField" /></td>
</tr>
</table>
</form>
function highlightElem(element) {
element = $(element);
//var cumulativeOffset = element.cumulativeOffset();
var top = $(''highlightTop'');
top.clonePosition(element, {setWidth: false, setHeight: false,
offsetLeft: -2, offsetTop: -2});
top.setStyle( { width: ( element.getWidth() + 4 ) + ''px'',
height:
''1px'' } );
//top.setStyle( { top: ( cumulativeOffset.top - 2 ) +
''px'', left:
( cumulativeOffset.left - 2 ) + ''px'', width: (
element.getWidth() +
4 ) + ''px'', height: ''1px'' } );
top.show();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---