Welcome Guest, Not a member yet? Register   Sign In
Codeigniter with jquery
#1

[eluser]jacobson[/eluser]
Hello I have a problem... i have a view which shows the data
Code:
foreach ($records as $item) {
    echo "<div id=\"content_main_entry\">(here i want to make a link with the $item->mine  inside as a link parameter)
            <span class=\"content_main_entry_value\">Value</span></div>
            <div id=\"content_main_entry_enroll\">(here i want to make link with id "iwanttoclickthis")Zapis</div>";
}

and now i want to have a script (so I add in the view file the script lines) which will after pressing the a#iwanttoclickthis show the alert with $item->mine

but there is a problem I cant make this in such a way
Code:
[removed]
    $(document).ready(function(){
        $("a#iwanttoclickthis").click(function(){
           var mine = &lt;?php echo $item->mine; ?&gt;;
           alert(mine);
        });
    });
[removed]

because my script does not recognise the $item->mine
how can I make this to work properly Smile
#2

[eluser]osci[/eluser]
You could produce your js function from php.
#3

[eluser]jacobson[/eluser]
sorry, I dont understand what you mean by that Tongue
#4

[eluser]Pegasus275[/eluser]
var mine = &lt;?php echo $item->mine; ?&gt;;
=>
var mine = '&lt;?php echo $item->mine; ?&gt;';
#5

[eluser]jacobson[/eluser]
It didnt change anything ... i don't have acces to the variable $item->mine in my JS script ( this variable appears in the php foreach loop )
#6

[eluser]Pegasus275[/eluser]
ok
Code:
foreach ($records as $item) {
    // you cant repeat id put class
    echo '<div class="wrap_me">';
    echo " <div class=\"content_main_entry\">".$item->mine."
            <span class=\"content_main_entry_value\">Value</span>
           </div>
           <div class=\"content_main_entry_enroll\">Zapis
                      <a >mine."\" class=\"volimseklikat\">KLIKNI ME JER SAM LIK</a>
           </div>";
    echo "</div>";
}
and magic goes here
Code:
$(document).ready(function(){
        $("a.volimseklikat").click(function(){
           alert('Href:'+$(this).attr('href'));
           alert('Text:'+$(this).html());
           alert('html wrap:'+$(this).parent().parent().html());
           alert('content_main_entry_value:'+$(this).parent().parent().find('.content_main_entry_value').text());
        });
    });

ok something like ....

ili tako nešto. Kaj uopce radis. Pogledaj si malo jquery???
#7

[eluser]jacobson[/eluser]
ok, i'll try that, and sory but I dont understand last sentence Tongue
#8

[eluser]Pegasus275[/eluser]
an in your code exists zapis?

what is zapis
#9

[eluser]jacobson[/eluser]
it's in polish Enroll




Theme © iAndrew 2016 - Forum software by © MyBB