anchor onclick and target=_blank |
[eluser]PHP Programmer[/eluser]
How can I set onclick function in CI's anchor function. I used the following: echo anchor("jobs/SaveJob/$search->jobs_emp_id/$search->employer_id", 'Save this job', "onclick=\"return [removed]save_job('$search->jobs_emp_id','$search->employer_id','$search->job_title')\""); I didn't get any JS function on clicking the link. Also, I want the page to be opened in new window. How can I use "target=_blank" along with the above statement. Also, I need a tooltip (to be called from database) on clicking the link. Please suggest...
[eluser]Weblizard[/eluser]
You need to set 3rd argument as an array, something like this should work: Code: $attr = array(
[eluser]chandrajatnika[/eluser]
I prefer use a normal anchor tag from HTML when I need a lot specification about my link Code: <a href="site_url('your/url')" target="_blank" onclick="yourevent()" title="your description">Your Link</a>
[eluser]Michael Wales[/eluser]
onclick... yucky yucky yucky Here's how I would do it, personally: Code: <?php echo anchor('jobs/SaveJob/' . $search->jobs_emp_id . '/' . $search->employer_id', 'Save this Job', array('title' => 'Save this Job', 'class' => 'save-job')); ?> I would then write the code so this function worked if Javascript was disabled. I would then use a library like jQuery to unobtrusively hijack all links with the save-job class and perform the AJAX function (I think that's what you are trying to accomplish here). Finally, I wouldn't open it in a new window unless I felt it was absolutely necessary. I absolutely hate sites that open new windows... I usually just close every window belonging to that site, never to return again. But, that's how I would do it. Weblizard's response should give you exactly what you are looking for.
[eluser]Jay Turley[/eluser]
Responding to Michael's post about applying unobtrusive javascript, I have to second his opinion of new windows, though I've mellowed in my old age. The jQuery library [1] will allow you to do what you want with ease. Then, you can use the jQmodal plugin [2] to do that neat "modal window" effect instead of opening a new window. Finally, I know there are several plugins for jQuery [3] which will handle tooltips for you as well. No sense trying to reinvent the wheel! [1] http://www.jquery.com [2] http://dev.iceburg.net/jquery/jqModal/ [3] http://www.google.com/search?q=tooltip+plugin+jquery |
Welcome Guest, Not a member yet? Register Sign In |