Welcome Guest, Not a member yet? Register   Sign In
jQuerty attr in Codeigniter


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

whats the value jQuery provides you in CI?

possibly post a little code or link

[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:

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

And the following URL structure

<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?

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.

pls, post all you jquery code

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:

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

header thats get included:
<!DOCTYPE html>
&lt;html dir="ltr" lang="sv-SE"&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;



    $(function() {
        $( "button, input:submit, a", ".demo" ).button();
        $( "a", ".demo" ).click(function() { return false; });
    $('b').attr('href', 'http://google.se');
   $("#click").bind('click', function(){
      return false
&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;}

    <div id="menu">
        <div id="menu-left"></div>
            <div id="menu-middle">
                <a href="start.php">Start</a>
        <div id="menu-right"></div>

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

Theme © iAndrew 2016 - Forum software by © MyBB