CodeIgniter Forums
jQuerty attr in Codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: jQuerty attr in Codeigniter (/showthread.php?tid=43984)



jQuerty attr in Codeigniter - El Forum - 07-29-2011

[eluser]Fredrik-s[/eluser]
Hello,

I try to open a link with jQuery's attr-code. But it doesn't work, the url won't change in Codeigniter. Is Codeigniter messing this up? For the exact same code works when not using Codeigniter.

Greetings Fredrik-s


jQuerty attr in Codeigniter - El Forum - 07-29-2011

[eluser]regal2157[/eluser]
whats the value jQuery provides you in CI?

possibly post a little code or link


jQuerty attr in Codeigniter - El Forum - 07-29-2011

[eluser]Fredrik-s[/eluser]
[quote author="regal2157" date="1311988959"]whats the value jQuery provides you in CI?

possibly post a little code or link[/quote]

Thanks for reply regal2157!

I use the following jQuery/Javascript code:

Code:
$('#linkness').attr('href', 'http://google.com');

And the following URL structure

Code:
<a id="linkness" href="#">An anchor</a>

When I the hover the link on a page where I use CI, I get the link structure of the current page I'm on and not "http://google.com". But when I do the exact same on a page not using CI, the link shows correct and I can click it and go to "http://google.com"

How come?


jQuerty attr in Codeigniter - El Forum - 07-29-2011

[eluser]regal2157[/eluser]
Is your jquery source correct?

also, I am not seeing the point of this honestly.. why would you not just make the href the link.


jQuerty attr in Codeigniter - El Forum - 07-29-2011

[eluser]byde[/eluser]
pls, post all you jquery code


jQuerty attr in Codeigniter - El Forum - 07-31-2011

[eluser]Fredrik-s[/eluser]
I found a thread - can't find it now - stating that CI breaks the jQuery link structure which makes the code provided not working. And there were some work around to manage the jQuery link structure.

Here is the code doe:

View-file
Code:
<div class="demo">
    <div id="demo-vanster"></div>
    <div id="demo-mitt">
        <a id="b" href="">Test link</a>
    </div>
    <div id="demo-hoger"></div>
</div>

header thats get included:
Code:
<!DOCTYPE html>
&lt;html dir="ltr" lang="sv-SE"&gt;
&lt;head&gt;
&lt;meta charset="UTF-8" /&gt;
&lt;title&gt;&lt;? echo $title ?&gt;&lt;/title&gt;
&lt;link rel="icon" href="link/images/favicon.png" type="image/png"/&gt;

&lt;link href='googleapis/css?family=Nobile' rel='stylesheet' type='text/css' /&gt;
&lt;link rel="stylesheet" type="text/css" media="all" href="link/css/style.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="link/jquery/development-bundle/themes/base/jquery.ui.all.css" /&gt;  
&lt;link rel="stylesheet" type="text/css" href="link/jquery/css/smoothness/jquery-ui-1.8.13.custom.css" /&gt;    
&lt;link rel="stylesheet" type="text/css" href="link/jquery/development-bundle/fastconfirm/jquery.fastconfirm.css"/&gt;

[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]

[removed][removed]
[removed][removed]

[removed]
    $(function() {
        $( "button, input:submit, a", ".demo" ).button();
        $( "a", ".demo" ).click(function() { return false; });
    });
    
    $('b').attr('href', 'http://google.se');
[removed]
[removed]
$(document).ready(function(){
   $("#click").bind('click', function(){
      $("#div_to_popup").bPopup();
      return false
   });
});
[removed]
&lt;style type="text/css"&gt;
    #div_to_popup {display:none;}
    #div_to_popup {
        background-color: #fff;
        height: 200px;
        width: 200px;
        -moz-border-radius: 15px;
        border-radius: 15px;
    }
    .bClose {cursor:pointer;font-weight:bold;position:absolute;right:15px;text-decoration:none;top:10px;}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
    <div id="menu">
        <div id="menu-left"></div>
            <div id="menu-middle">
                <a href="start.php">Start</a>
            </div>
        <div id="menu-right"></div>
    </div>



jQuerty attr in Codeigniter - El Forum - 07-31-2011

[eluser]byde[/eluser]
$('b').attr('href', 'http://google.se'); ???????
try $('#b').attr('href', 'http://google.se');