Notices

Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Force Javascript to run

Post Reply New Thread Subscribe Search this Thread
 
 
Thread Tools
Old 07-21-10, 03:25 PM Thread Starter   #1
TheGame240
Member

 
TheGame240's Avatar 

Join Date: Oct 2002
Location: Muscle Shoals, AL

10 Year Badge
 
Force Javascript to run


I've created an administrative page and used the tab browsing method shown here. Now the problem I'm having is that I need to integrate ckeditor into some of the tabs.

Using their instructions for integration, the editor will work in a standard PHP/HTML page. But in the tabbed page, all I was getting was a standard textarea and a submit button. I thought something might be wrong with my echo statements in the content generator, but after trying them in a straight PHP script, they work fine. I've come to the conclusion that the editor isn't showing up because the Javascript doesn't execute in the tabbed environment. I tested by adding a double click event that will call the ckeditor script. This will work in the tabbed page, but isn't any kind of solution.

Basically I have two scripts. One replaces div content when a new tab is clicked. The other is to create the editor instance. The script to create the editor instance isn't being called after the first script replaces the div content even though there is a script call being generated. I'm guessing that it has something to do with the scripts only being processed on the initial page load since the exact same calls will work in a standard page.

What I need is a way to make the ckeditor script run when the appropriate tabs are selected. To further complicate the matter, the ckeditor script has to be run after the textarea, p, etc it's replacing is generated.
TheGame240 is offline   QUOTE Thanks
Old 07-21-10, 04:17 PM   #2
petteyg359

 
petteyg359's Avatar 

Join Date: Jul 2004
Location: University of Southern Mississippi

 
Try calling the ck script in an onfocus in its div.

EDIT: The tabbing setup you've linked isn't generally accepted as best practice. Just have each tab in a div, and have the javascript change the style display attribute.

Code:
<div id="menu"><a href="#" onclick="tab(1);">Tab1</a> | <a href="#" onclick="tab(2);">Tab2</a> | <a href="#" onclick="tab(3);">Tab3</a></div>
<div id="tab1">Content1</div>
<div id="tab2">Content2</div>
<div id="tab3">Content3</div>
<script type="text/javascript">
<!--
numTabs = 3;
function hideAll() {
 for (i = 0; i < numTabs; i++) { document.getElementById("tab"+i).style.display = "none"; }
}
function tab(n) {
 hideAll();
 document.getElementById("tab"+n).style.display = "";
}
tab(1);
-->
</script>
The tab(1); at the last script line will make sure only tab1 is displaying when the page is loaded, if javascript is enabled. You'll need some CSS work to make all the tabs show up in the same spot, but you get separation of logic and content.

__________________
MSI 890GXM-G65 - X6 1055T - 16GiB 10700 - 5850 1GiB - 7 Pro x64 / Gentoo amd64 - HX520
Dell XPS 15 L502x - i7 2760QM - 16GiB 12800 - GT 540M 2GiB - 7 Pro x64 / Gentoo amd64 - Agility 4 512GB

[GB ≠ GiB] [MB ≠ MiB] [kB ≠ kiB] [1000 ≠ 1024] [Giga ≠ gram] [Mega ≠ milli] [Kelvin ≠ kilo] [Byte ≠ bit]
"Apparently, Plaintiff believes that he could sue an egg company for fraud for labeling a carton of 12 eggs a “dozen,” because some bakers would view a “dozen” as including 13 items." - Western Digital 2006

Last edited by petteyg359; 07-21-10 at 04:33 PM.
petteyg359 is offline Folding Profile SETI Profile Heatware Profile   QUOTE Thanks
Thanks!
TheGame240 (07-23-10)
Old 07-22-10, 12:43 PM   #3
elxx
Registered



Join Date: Jul 2010
Location: Tucson AZ

 
Man if I were you, I'd just use a premade tabbing system out of jquery. I really can't imagine why you'd use straight javascript over a framework.

http://jqueryui.com/themeroller/ <---that would be pretty quick. Or you can google one someone else made which would work just as well.
elxx is offline   QUOTE Thanks
Thanks!
TheGame240 (07-23-10)
Old 07-22-10, 06:12 PM   #4
petteyg359

 
petteyg359's Avatar 

Join Date: Jul 2004
Location: University of Southern Mississippi

 
Quote:
Originally Posted by elxx View Post
I really can't imagine why you'd use straight javascript over a framework.
I can quite easily imagine why someone might do such a thing. Sometimes all you need is some simple tabbing, and a few hundred bytes of simple tabbing code is enough. Why spend 24KiB bandwidth when 240B will do just fine?

__________________
MSI 890GXM-G65 - X6 1055T - 16GiB 10700 - 5850 1GiB - 7 Pro x64 / Gentoo amd64 - HX520
Dell XPS 15 L502x - i7 2760QM - 16GiB 12800 - GT 540M 2GiB - 7 Pro x64 / Gentoo amd64 - Agility 4 512GB

[GB ≠ GiB] [MB ≠ MiB] [kB ≠ kiB] [1000 ≠ 1024] [Giga ≠ gram] [Mega ≠ milli] [Kelvin ≠ kilo] [Byte ≠ bit]
"Apparently, Plaintiff believes that he could sue an egg company for fraud for labeling a carton of 12 eggs a “dozen,” because some bakers would view a “dozen” as including 13 items." - Western Digital 2006
petteyg359 is offline Folding Profile SETI Profile Heatware Profile   QUOTE Thanks
Old 07-24-10, 03:21 AM   #5
elxx
Registered



Join Date: Jul 2010
Location: Tucson AZ

 
Quote:
Originally Posted by petteyg359 View Post
I can quite easily imagine why someone might do such a thing. Sometimes all you need is some simple tabbing, and a few hundred bytes of simple tabbing code is enough. Why spend 24KiB bandwidth when 240B will do just fine?
Productivity. Use a framework and save yourself a half hour. Now days its all about how quickly you can crank out a project/app. Bandwidth is rarely a limiting factor.
elxx is offline   QUOTE Thanks
Old 07-24-10, 08:48 AM   #6
petteyg359

 
petteyg359's Avatar 

Join Date: Jul 2004
Location: University of Southern Mississippi

 
Quote:
Originally Posted by elxx View Post
Productivity. Use a framework and save yourself a half hour. Now days its all about how quickly you can crank out a project/app. Bandwidth is rarely a limiting factor.
For something simple like tabs where only a few lines of code are required, you're not saving any time at all. It takes just as much time to read and figure out how the library does it. You're arguing that one should use a heavy duty wet/dry "shop vac" with 18 attachments for some spilled flour on the counter, when a wet rag will do just fine.

__________________
MSI 890GXM-G65 - X6 1055T - 16GiB 10700 - 5850 1GiB - 7 Pro x64 / Gentoo amd64 - HX520
Dell XPS 15 L502x - i7 2760QM - 16GiB 12800 - GT 540M 2GiB - 7 Pro x64 / Gentoo amd64 - Agility 4 512GB

[GB ≠ GiB] [MB ≠ MiB] [kB ≠ kiB] [1000 ≠ 1024] [Giga ≠ gram] [Mega ≠ milli] [Kelvin ≠ kilo] [Byte ≠ bit]
"Apparently, Plaintiff believes that he could sue an egg company for fraud for labeling a carton of 12 eggs a “dozen,” because some bakers would view a “dozen” as including 13 items." - Western Digital 2006
petteyg359 is offline Folding Profile SETI Profile Heatware Profile   QUOTE Thanks

Post Reply New Thread Subscribe


Overclockers Forums > Software > Programming Tips and Tricks
Programming Tips and Tricks
Forum Jump

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Mobile Skin
All times are GMT -5. The time now is 08:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
You can add these icons by updating your profile information to include your Heatware ID, Benching Profile ID or your Folding/SETI profile ID. Edit your profile!
X

Welcome to Overclockers.com

Create your username to jump into the discussion!

New members like you have made this the best community on the Internet since 1998!


(4 digit year)

Why Join Us?

  • Share experience
  • Max out your hardware
  • Best forum members anywhere
  • Customized forum experience

Already a member?