You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tubin gen <fa...@gmail.com> on 2009/04/10 20:59:04 UTC

image path for my java script

I need image path in my java script , I  want collapsable behavior
for my component  , to which i add either plus or minus , when user
click on the imaghe my java script   get the image with component and
checks the src to find if it  is plus or minus , and   finally changes
the image to the oppsite here is my java script
[code]
				$(document).ready(function(){
				  $("p.collapsible_text").click(
				  		
					  function () {
						  var $img= $(this).children("img");
						  var $div= $(this).next("div");
						  var $label=$(this).children("label");	
						  var imgSrc=$img.attr("src");
					      if($img.attr("src") ==
"resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/plus.png"){
						     $div.slideDown("fast");    			
 							 $label.html("Close");
 							 $img.attr("src","resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/minus.png");
 							 return;	
						  }
					      if($img.attr("src") ==
"resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/minus.png"){
							     $div.slideUp("fast");    			
	 							 $label.html("Open");
	 							 $img.attr("src","resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/plus.png")
						  }
					  }
					);
			});

[code]
now the problem is  I  hardcoded the image path in java script  but
the image path changes   becasue this sciprt gets added by my
collapsable panel and any page from any directory might use this panel
so the image path is different to different pages so need suggestions
on how to   hard code image path in this java script

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: image path for my java script

Posted by Igor Vaynberg <ig...@gmail.com>.
the easiest way to deal with images is to always use css, that way
images are always loaded relative to css and you dont have a problem.
instead of an img tag add a <div class="plus"> and have div.plus {
background: url('plus.gif'); width:20px;height:20px; }

other then that you can always build a url using urlfor() methods on
component and request cycle and pas those as parameters to your
script.

-igor

On Fri, Apr 10, 2009 at 11:59 AM, tubin gen <fa...@gmail.com> wrote:
> I need image path in my java script , I  want collapsable behavior
> for my component  , to which i add either plus or minus , when user
> click on the imaghe my java script   get the image with component and
> checks the src to find if it  is plus or minus , and   finally changes
> the image to the oppsite here is my java script
> [code]
>                                $(document).ready(function(){
>                                  $("p.collapsible_text").click(
>
>                                          function () {
>                                                  var $img= $(this).children("img");
>                                                  var $div= $(this).next("div");
>                                                  var $label=$(this).children("label");
>                                                  var imgSrc=$img.attr("src");
>                                              if($img.attr("src") ==
> "resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/plus.png"){
>                                                     $div.slideDown("fast");
>                                                         $label.html("Close");
>                                                         $img.attr("src","resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/minus.png");
>                                                         return;
>                                                  }
>                                              if($img.attr("src") ==
> "resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/minus.png"){
>                                                             $div.slideUp("fast");
>                                                                 $label.html("Open");
>                                                                 $img.attr("src","resources/gov.hhs.acf.web.pages.common.collapsable.AbstractCollapsablePanel/plus.png")
>                                                  }
>                                          }
>                                        );
>                        });
>
> [code]
> now the problem is  I  hardcoded the image path in java script  but
> the image path changes   becasue this sciprt gets added by my
> collapsable panel and any page from any directory might use this panel
> so the image path is different to different pages so need suggestions
> on how to   hard code image path in this java script
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org