Question
(Moved here from
TwistyPluginDev) I have been trying to find out, why Twisty is breaking my page autocomplete feature in
QuickMenuSkin, TWiki 4.1.2. Every time there is a twisty in a page, ajax requests (
TWikiAjaxContrib) don't work (they worked in TWiki 4.0.5). Maybe there is some clash of names? Is there a non-compressed version of Twisty somewhere, maybe compression is causing it?
Aside from this, I found that
twiki.js is loaded second time whenever twisty is used. Is there a good reason to do this?
Environment
--
MikkoLaakso - 01 Jul 2007
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
What version of contribs/plugins are you using?
--
ArthurClemens - 30 Jun 2007
Seriously, I thought I updated my plugins, but seems I only did it in my workplace. Sorry. Seems Twisty uses the new twiki javascripts now and does not load
twiki.js .
But alas, the problem with Ajax persists even after update. It is enough to write
%TWISTY{}%
my twisty content
%ENDTWISTY%
and the ajax requests (at least the ones I use) no longer work. There are no attempts to download the page with topic list (I would see it from firebug "Console"). The calls are:
More... Close
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/TWikiAjaxContrib/twikiAjaxRequest.compressed.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/BehaviourContrib/behaviour.compressed.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/TWikiJavascripts/twikiHTML.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/yahoo/yahoo.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/connection/connection.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/autocomplete/autocomplete.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/event/event.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/dom/dom.js"></script>
<script type="text/javascript">
// <![CDATA[
var javascriptPageUrl = "%SCRIPTURL{"view"}%/%TWIKIWEB%/TopicListForJS?skin=text" + ";section=javascript" + ";web=%WEB%";
function initAutocompleteLoad () {
twiki.AjaxRequest.load("AUTOCOMPLETEFORM_JS",
{
url:javascriptPageUrl,
type:"script",
cache:true
})
}
var autocompleterules = {
'#pagesautocomplete' : function(el) {
el.onclick = function() {
initAutocompleteLoad();
return false;
}
}
};
Behaviour.register(autocompleterules);
// ]]>
</script>
(I am not an experienced javascript programmer btw, probably it shows)
The twisty javascript is downloaded after YUI javascripts. Is there a debugger I could use or something I could do to debug this?
--
MikkoLaakso - 01 Jul 2007
From your code I cannot see which twisty scripts are loaded, your code does not seem to have anything to do with the twisty?
But it is possible the old templates do not include all necessary files (I though they would). In
LitterTray
is a test with the new version (TWiki 4.2).
I use Firefox that has the Error Console - very useful to track down bugs.
--
ArthurClemens - 01 Jul 2007
Error console does display two warnings (about stylesheets) but no errors. The warnings are the same when I access a page with or without a twisty, the difference is still that it breaks
TWikiAjaxContrib. Pretty weird...
How come everything works in TWiki 4.0.5, with twisty also? This is beyond me. What is there in the upgrade that could have broken Ajax, when combined with Twisty?
Lets see. In 4.0.5 I currently have Twisty plugin 1.2.0, $Rev: 11829$, Contrib version 25 Oct 2006 1.2, behavior 1.000 (1.1),
TWikiAjaxContrib 15 Nov 2006 0.8.4. In my 4.1.2 development install I have
same behavior and
TWikiAjaxContrib + latest Twisty, although before I had the same Twisty plugin+contrib versions but problems did not change.
I have a test to reproduce this, see if you add the lines
%TWISTY{}%
my twisty content
%ENDTWISTY%
to the Plugins.
TWikiAjaxContribExamples page (when installed), the twisty
will not display. Although in my case it is the other way around, this proves there is a clash between the two.
What happened in between 4.0.5 and 4.1.2 that broke the combination TWikiAjaxContrib + TwistyPlugin?
--
MikkoLaakso - 01 Jul 2007
Hmm, my
YahooUserInterfaceContrib needs update, I will see if that fixes the problem.
--
MikkoLaakso - 01 Jul 2007
No, no difference. The fault is still elsewhere.
- Could it be a namespace clash?
- It is YUI connect.js that is called when downloading the pagelist in my case.
--
MikkoLaakso - 01 Jul 2007
It is still not clear what is not working. Do you have code that I can test?
BTW, there is now
AutoCompleteAddOn and
AutoCompletePlugin.
--
ArthurClemens - 01 Jul 2007
The skin update for TWiki 4.1.2 proto is near finished and you can get it from
QuickMenuSkinDev (no installer available yet). You need to untar it and set ownership rights. I am working on an installer, update will follow shortly. I will also provide you the minimal code for the autocomplete feature here:
In your TEMPLATESCRIPT, put the following:
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/TWikiAjaxContrib/twikiAjaxRequest.compressed.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/BehaviourContrib/behaviour.compressed.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/TWikiJavascripts/twikiHTML.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/yahoo/yahoo.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/connection/connection.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/autocomplete/autocomplete.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/event/event.js"></script>
<script type="text/javascript" src="%PUBURL%/%TWIKIWEB%/YahooUserInterfaceContrib/build/dom/dom.js"></script>
<script type="text/javascript">
// <![CDATA[
var javascriptPageUrl = "%SCRIPTURL{"view"}%/%TWIKIWEB%/TopicListForJS?skin=text" + ";section=javascript" + ";web=%WEB%";
function initAutocompleteLoad () {
twiki.AjaxRequest.load("AUTOCOMPLETEFORM_JS",
{
url:javascriptPageUrl,
type:"script",
cache:true
})
}
var autocompleterules = {
'#pagesautocomplete' : function(el) {
el.onclick = function() {
initAutocompleteLoad();
return false;
}
}
};
Behaviour.register(autocompleterules);
// ]]>
</script>
In TWiki web, create a page named
TopicListForJS:
%STARTSECTION{"javascript"}%
<noautolink>
var pagesArray = [ %TOPICLIST{"\"$name\"" separator=", " web="%URLPARAM{"web"}%"}% ]; oAutoCompleteDS = new YAHOO.widget.DS_JSArray(pagesArray); pageAutoComp = new YAHOO.widget.AutoComplete('pagesinput', 'pagescontainer', oAutoCompleteDS); pageAutoComp.queryDelay = 0; pageAutoComp.prehighlightClassName = "yui-ac-prehighlight"; pageAutoComp.typeAhead = false;
</noautolink>
%ENDSECTION{"javascript"}%
Somewhere in your topic (e.g. view template) put the following HTML:
<form action="%SCRIPTURLPATH{"view"}%/%BASEWEB%/%BASETOPIC%">
<div id="pagesautocomplete" autocomplete="off">
<input id="pagesinput" type="text" name="topic" value="%MAKETEXT{"Jump"}%" class="twikiInputBox twikiInputBoxDefault" onfocus="clearDefaultandCSS(this)" onblur="setDefaultandCSS(this)" autocomplete="off"></input>
<div id="pagescontainer">
</div>
</div>
</form>
--
MikkoLaakso - 06 Jul 2007
When you click on the form box, it will download the pagelist
unless there is a twisty on the same page. Btw, I am using the
TWikiAjaxContrib pre-release javascripts (the ones included above).
--
MikkoLaakso - 06 Jul 2007
http://develop.twiki.org/~twiki4/cgi-bin/view/LitterTray/AutoCompleteTest
--
MikkoLaakso - 06 Jul 2007
I believe I have fixed this in the latest
BehaviourContrib (1.2.1):
Bugs:Item4329
.
Again, please review
AutoCompleteAddOn and
AutoCompletePlugin. Try to further minimize duplications.
--
ArthurClemens - 06 Jul 2007
This seems to be answered...
--
PeterThoeny - 02 Sep 2007