Welcome Guest, Not a member yet? Register   Sign In
Help - can this jquery script work with codeigniter?
#1

[eluser]dippy[/eluser]
i have been trying to get this jquery popup script to work with codeigniter and the MVC setup but i cannot get it to work at all except with just an html page...

here is the link to the tutorial.
-http://karlagius.com/2009/02/08/creating-a-sitepoint-like-sliding-popup-in-jquery/

first thing i did was upload the popup.html to the root folder of the site. i also tried the controller folder and still nothing is popping up...

so heres how i did it...

created a controller called test. and a view called test. (in the next post)

here is the codeigniter (MVC structure) demo which is not working.
-http://dev.dbhosts.net/50dollartow/index.php/test

i also have the demo setup in its own folder. and it works fine. not using the MVC structure. but using the same js script.
-http://dev.dbhosts.net/50dollartow/popup/

BOTH are using the same js script. When i view source on both demos they look identical.

is it because the js script is looking for another html page but cannot find it because of the sites MVC structure?

any help is very greatful

Thanks in advance.
#2

[eluser]dippy[/eluser]
controller:
Code:
<?php
class Test extends Controller {

    function Test()
    {
        parent::Controller();
    }

    function index()
    {
        /**
         * SEO / Meta / exta head tag info.
         */
        $data['description'] = "50DollarTow.Com - Bringing accountablility to towing";
        $data['keywords'] = "Towing, Cars, 247 towing";
        $data['title'] = "50DollarTow.Com! Bringing accountablility to towing";
        $data['extraHeadContent'] = '
        [removed][removed]
        [removed][removed]
        [removed]
            $(document).ready(function () {
                    // This check is used by the demo to allow you to remove the cookie. Do not use in production code.
                    if (HasAlreadyReceivedPopup("testpopup"))
                        $("#note").show().click(function () {
                            [removed] = name + "testpopup=;path=/;expires=Thu, 01-Jan-1970 00:00:01 GMT"; location.reload(true);
                        });

                    CreatePopup("popup.html", 200, 1500, "testpopup", 5);
            });
        [removed]
        <style>
            #content, #note { text-align:justify; width:300px; }
            #note { border:2px solid #D84; margin-bottom:1em; display:none; background-color:yellow; padding:5px; cursor:default; }
            #sliding_popup { position:fixed; left:0px; display:block; width:100%; padding:0px; margin:0px; }
        </style>
';


        //put your code here



        //loads the data into the view
        $this->load->view('test', $data);
    }


}


?>

view:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Sliding popup test page&lt;/title&gt;
    &lt;?php
    //extra head content
    if (isset($extraHeadContent)) {
        echo $extraHeadContent;
    }

    ?&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <h1>Sliding popup test page</h1>
        <div id="note">The popup will not be displayed because its cookie has already been set. We use this to avoid showing the popup multiple times to the same user, which would be really annoying. Click on this message to remove the cookie and reload the page.</div>
        <div id="content">
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nisl. Nulla aliquet leo dapibus nunc. Nulla facilisi. Proin faucibus, erat non consectetur fermentum, ante nibh euismod pede, in laoreet lectus nibh vitae turpis. Cras condimentum lorem ac felis. Vestibulum tempus, sem venenatis condimentum adipiscing, turpis lacus hendrerit mi, sit amet varius tellus elit quis lorem. Phasellus pellentesque nisi sed enim. Phasellus nulla nisi, iaculis non, vulputate eget, vehicula at, risus. In sit amet purus vel massa fermentum tempus. Integer a lacus a nibh varius porta. Vivamus nec elit vitae arcu eleifend elementum. Proin ornare felis interdum turpis.</p>
            <p>Nullam sit amet quam vel orci luctus feugiat. Duis molestie fermentum purus. Nunc tincidunt semper dolor. Curabitur volutpat elit et lacus. Vestibulum libero. Mauris justo est, ullamcorper faucibus, molestie id, accumsan sed, ante. Fusce sed leo et nisl bibendum elementum. Ut cursus. Quisque enim ante, tincidunt quis, pulvinar sit amet, tincidunt id, metus. Fusce non odio vitae dolor tristique dapibus. Aenean placerat posuere lectus. Nulla blandit pharetra lectus. Nullam id dolor. Praesent convallis, purus vel elementum dapibus, sem nibh eleifend odio, nec ornare leo elit ac neque. Donec eu orci luctus nunc vehicula varius. Vivamus pellentesque lacinia purus.</p>
            <p>Praesent eu orci. Proin dictum. Mauris malesuada congue libero. Fusce diam. Nullam rutrum. Quisque sodales magna id mauris. Morbi molestie, eros eu aliquam volutpat, nisi nulla elementum tortor, ut hendrerit metus libero vitae mi. Aliquam scelerisque mattis massa. Fusce sagittis, elit ut ultricies placerat, neque augue elementum diam, id mattis metus nisi quis metus. Fusce tincidunt commodo nibh. Suspendisse id urna fermentum mi vulputate condimentum. Suspendisse potenti. Fusce vehicula nisl in enim.</p>
            <p>Mauris fermentum, massa congue hendrerit dictum, augue neque convallis lorem, dapibus fermentum odio neque nec justo. Sed ligula mi, vestibulum nec, fermentum faucibus, suscipit a, lectus. Vestibulum ligula. Duis ut ligula id lacus varius placerat. In varius. Duis nulla. Morbi eu libero non mi varius elementum. Aenean elementum tincidunt leo. Etiam id quam. Maecenas quis lacus. Nulla dui mi, bibendum sed, facilisis id, egestas quis, sem. Etiam rutrum velit a tortor. Donec sit amet nulla vitae eros elementum facilisis. Quisque interdum odio vel risus. Phasellus eros lectus, faucibus a, vulputate vulputate, cursus a, tortor. Praesent posuere. Quisque ornare ante et leo. Nulla est mi, pharetra eget, facilisis eu, ullamcorper ac, nunc. Aliquam posuere quam dapibus lectus. Vivamus nisl lorem, volutpat a, accumsan porttitor, tincidunt id, enim.</p>
            <p>Curabitur auctor. Maecenas dapibus. Pellentesque ligula erat, luctus eu, commodo blandit, scelerisque vitae, enim. Nullam at tortor a velit eleifend tristique. Nunc ornare gravida risus. Morbi tristique leo id dui. Donec in leo. Ut sagittis lectus at elit. Suspendisse in pede vitae dui condimentum viverra. Phasellus adipiscing tortor sed orci. Nulla ac magna. Morbi gravida elit vel sem. Phasellus luctus. </p>
        </div>
    &lt;/body&gt;
&lt;/html&gt;

Thanks again.
#3

[eluser]srisa[/eluser]
I don't know if this is an elegant solution, but give it a try.
Create a function in the test controller with name "popup" which displays the pop up containing the contents of the current popup.html. Call your CreatePopup like so
Code:
CreatePopup('http://dev.dbhosts.net/50dollartow/index.php/test/popup', 200, 1500, "testpopup", 5);
#4

[eluser]dippy[/eluser]
Thanks that worked.




Theme © iAndrew 2016 - Forum software by © MyBB