Jump to:

23370 Posts in 18145 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » javascript not working in page

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

Page: 1
Go to End
Author Topic: 1372 Views
  • Rishi
    Avatar
    Community Member
    97 Posts

    javascript not working in page Link to this post

    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

    Attached Files
  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: javascript not working in page Link to this post

    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

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: javascript not working in page Link to this post

    try to add the javascript line in page.ss

  • Rishi
    Avatar
    Community Member
    97 Posts

    Re: javascript not working in page Link to this post

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

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: javascript not working in page Link to this post

    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?

  • Rishi
    Avatar
    Community Member
    97 Posts

    Re: javascript not working in page Link to this post

    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

    1372 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.