• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
load event in javascript/jquery library doesn't work

#1
[eluser]Giorgio Nordo[/eluser]
In my controller I would like to hide a div identified with the id #divpannello during the loading of every page.
I used this code:
Code:
function __construct()
    {
      parent::__construct();
      $data = array();
      $codice = $this->javascript->hide('#divpannello');
      $this->javascript->load('#dummy', $codice);  /
      $this->javascript->compile();
    }

where #dummy is an id for an image used in my view

Code:
<img id="dummy" src="&lt;?php echo site_url(); ?&gt;application/views/images/dummy.png" />

just for allowing the load (I'm quite new oto jquery and I am not sure this is the simple and correct way).

The problem is that the jquery script seems work ONLY when I manually refresh the page.
Obviously, I would like to automatically run the jquery script when I pass to any page without reloading it.

Could someone help me insolving this trouble?
Thanks in advance,
Giorgio

#2
[eluser]steelaz[/eluser]
I'm not a big fan of CI javascript library, so I can only suggest adding JS code in your view file. Here is how you hide an element with jQuery (first line loads jQuery from Google CDN):

Code:
<scr.ipt type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></scr.ipt>
<scr.ipt type="text/javascript">
    $(document).ready(function(){
        $('#dummy').hide();
    });
</scr.ipt>

#3
[eluser]Giorgio Nordo[/eluser]
Thank you for your quick reply.
As I told I am a newbie wicth JQuery and I preferred to use JavaScript library because a better compatibility but I'll follow your suggestion to avoid it and to embed directly the Jquery code in the view.
Giorgio

#4
[eluser]InsiteFX[/eluser]
It's does not have better compatibility to me it is overkill and I will not use it.

For jQuery use it's no conflict.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.