Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

javascript not working in page


Reply


6 Posts   1436 Views

Avatar
Rishi

Community Member, 97 Posts

21 January 2010 at 11:27am

Edited: 21/01/2010 11:28am

Hello
I am trying to add RevealingPhotoSlide in my page,I have 2 js file and one css file and few images,i have saved the css file under themes/template/blackcandy/css and images under themes/template/blackcandy/images ,I need to include the js file in my page and html code in my page,this is how i am doing it.
i have added the below code in my page.php file

public function init() {
      parent::init();

      Requirements::themedCSS("layout");
      Requirements::themedCSS("typography");
      Requirements::themedCSS("form");

// my added line
Requirements::themedCSS("style");
      Requirements::javascript('mysite/javascript/jquery.js');
      Requirements::javascript('mysite/javascript/photorevealer.js');    
//adding ended here   
   }
   

in Page.ss just under the layour div i have added the below lines
<div id="page-wrap">
   
      <h1>Revealing Photo Slider</h1>
      
      <table><tr>
      
      <td><div class="photo_slider">
         <img src="http://localhost/cs_login/themes/blackcandy/images/mthood.jpg"/>
         <div class="info_area">         </div>
      </div></td>
      
<td><div class="photo_slider">
   <img src="http://localhost/cs_login/themes/blackcandy/images/baloon.jpg"/>
   <div class="info_area">   </div>
</div></td>
      
      <td><div class="photo_slider">
         <img src="http://localhost/cs_login/themes/blackcandy/images/lighthouse.jpg"/>
         <div class="info_area">         </div>
      </div></td>
      
      <td><div class="photo_slider"> <img src="http://localhost/cs_login/themes/blackcandy/images/giraffe.jpg"/>
<div class="info_area"> </div>
       </div></td>
      </tr></table>
         
   </div>

What i am getting is four images in my page without any button for click...in the script i use to get a picture to click so that the image gets bigger.
I have attached the file hwere the script is working fine in simple html.
Hoping that someone will let me know the error and ways to make this working
thank you in advance

Avatar
MateuszU

Community Member, 89 Posts

21 January 2010 at 5:32pm

The code looks good. Make sure your jquery is not clashing with ss jquery which is for example included with SS navigation bar. Do you have firebug installed? Is it reporting any errors in the console? Is the jquery.js and the photorevealer.js got loaded correctly.

Note: if you have Chrome, it has a debugger built in, you can start it via Viev>Developer>Developer Tools. You can also use IEDeveloperToolbar on IE8, although this is a beast :)

Avatar
Webdoc

Community Member, 333 Posts

21 January 2010 at 6:38pm

try to add the javascript line in page.ss

Avatar
Rishi

Community Member, 97 Posts

24 January 2010 at 8:23am

i have tried all the steps but no error and even writting in page.ss does not works

Avatar
zenmonkey

Community Member, 532 Posts

24 January 2010 at 9:20am

Well if you're getting a Blank Page with no HTML at all you're either calling a bad control or you have a typo somewhere. When you dev/build does it finish?

Avatar
Rishi

Community Member, 97 Posts

26 January 2010 at 8:04am

except the javascript part the rest of the page is working fine..
the images are showing up in the page but the javascript is not working