PDA

View Full Version : Javascript in SS7 plugin settings HTML



GoCubs
2007-07-17, 09:22
In my plugin settings page I use some custom javascript functions. They used to work fine, but something changed in the nightlies in the past few weeks that prevents the browser from finding the javascript function.

I have the functions defined after [% PROCESS settings/header.html %] within a <script type="text/javascript"> tag.

When a button on my settings page tries to execute the function I get a [function name] is not defined in my error console.

For some reason I'm also not able to view source of the particular frame that contains all my settings code which makes debugging more painful.

Any ideas on what I need to do to get the function visible?

Much thanks
-Greg

kdf
2007-07-17, 09:56
Quoting GoCubs <GoCubs.2tvinn1184689501 (AT) no-mx (DOT) forums.slimdevices.com>:


> I have the functions defined after [% PROCESS settings/header.html %]
> within a <script type="text/javascript"> tag.

That should work, but if you are not getting any source then that
would point to a Template Toolkit error which would cause the page to
fail to render fully and can often block the ability to view source.
Run the server from the command line to help debug. It will spit out
and TT errors to the prompt window/terminal.

Nothing has changed much in the way settings are handled by the
nightlies as far as I am aware. If you can get a hold of an SVN
client, that would allow you to easily go back to any specific change
number that you want. When things do break, having the change number
that caused it really helps.
-kdf

GoCubs
2007-07-17, 10:20
Quoting GoCubs <GoCubs.2tvinn1184689501 (AT) no-mx (DOT) forums.slimdevices.com>:

That should work, but if you are not getting any source then that
would point to a Template Toolkit error which would cause the page to
fail to render fully and can often block the ability to view source.
Run the server from the command line to help debug. It will spit out
and TT errors to the prompt window/terminal.

Nothing has changed much in the way settings are handled by the
nightlies as far as I am aware. If you can get a hold of an SVN
client, that would allow you to easily go back to any specific change
number that you want. When things do break, having the change number
that caused it really helps.
-kdf

I'm not able to view source for any of the plugin settings pages (RSS, Date/Time, etc.). In Firefox if I right click on the frame and say "This Frame" and view source I get source, but it doesn't include the settings HTML that I'm viewing.

From what I remember the code used to work before the "Save Settings" button was moved into a separate frame on the bottom of the page.

-Greg

mherger
2007-07-17, 10:36
> I'm not able to view source for any of the plugin settings pages (RSS,
> Date/Time, etc.). In Firefox if I right click on the frame and say
> "This Frame" and view source I get source, but it doesn't include the
> settings HTML that I'm viewing.

That's because it's loaded dynamically, the full page isn't reloaded.
Please install FireBug (a FF extension) and see whether you can see your
JS in there.

And did you try turning on http debugging? This should tell you if TT has
problems parsing the templates.

Michael

kdf
2007-07-17, 10:54
Quoting GoCubs <GoCubs.2tvlfn1184693102 (AT) no-mx (DOT) forums.slimdevices.com>:


> I'm not able to view source for any of the plugin settings pages (RSS,
> Date/Time, etc.). In Firefox if I right click on the frame and say
> "This Frame" and view source I get source, but it doesn't include the
> settings HTML that I'm viewing.
>
> From what I remember the code used to work before the "Save Settings"
> button was moved into a separate frame on the bottom of the page.

ah right. I wasnt thinking back quite far enough. The pages for
settings are reloaded via an ajaxupdater on the settings div. You'll
get the source if you use firebug with firefox and watch the console
for the page response.

The evalscripts param is set, so the scripts should still be working.
Do you have a link for the current download? I can maybe try it out
here.

-kdf

GoCubs
2007-07-17, 12:02
>
That's because it's loaded dynamically, the full page isn't reloaded.
Please install FireBug (a FF extension) and see whether you can see your
JS in there.

And did you try turning on http debugging? This should tell you if TT has
problems parsing the templates.

OK, Installed Firebug. Pretty cool. I can't find my javascript in any of the pages under the script tab though.

HTTP debugging doesn't complain about anything...


Quoting GoCubs <GoCubs.2tvlfn1184693102 (AT) no-mx (DOT) forums.slimdevices.com>:

ah right. I wasnt thinking back quite far enough. The pages for
settings are reloaded via an ajaxupdater on the settings div. You'll
get the source if you use firebug with firefox and watch the console
for the page response.

The evalscripts param is set, so the scripts should still be working.
Do you have a link for the current download? I can maybe try it out
here.


Please give er a check:
http://gregbrown.net/squeeze/SuperDateTime/SuperDateTime071707.zip

From within the SuperDateTime settings page there is a button labeled "Add Custom Mode". That's the one that's not firing the associated javascript.

Much thanks!
-Greg

kdf
2007-07-17, 12:38
I've quickly grabbed and attached the source that I got from the
firebug console. The script fails due to the error: addRowInnerHTML is
not defined.
The source does seem to have the script, so it will take a bit more
looking around.

kdf
2007-07-17, 17:26
It turns out that functions used within an updater response will not
work. You need to assign them to variables.

ie:

function addRowInnerHTML(tblId)
function deleteRow(r)

become

addRowInnerHTML = function(tblId)
deleteRow = function(r)

-kdf

GoCubs
2007-07-17, 17:51
It turns out that functions used within an updater response will not
work. You need to assign them to variables.

ie:

function addRowInnerHTML(tblId)
function deleteRow(r)

become

addRowInnerHTML = function(tblId)
deleteRow = function(r)

That did it! I swear the old way used to work!

Thanks for figuring the work around. I was trying all sorts of things with even the most simple function with no luck.

-Greg

kdf
2007-07-17, 18:04
On 17-Jul-07, at 5:51 PM, GoCubs wrote:
>>
> That did it! I swear the old way used to work!
>
> Thanks for figuring the work around. I was trying all sorts of things
> with even the most simple function with no luck.
>
Spend some time here:
http://wiki.script.aculo.us


Slimserver 7 makes use of prototype.js and the scriptaculous ajax
libraries. They are loaded with most of the headers so
you can always make use of the info there to add effects or in this
case, find out why functions won't work :)

-kdf