Alberto,

Here is an example of how to listen to the preview-change method Blair
is referencing.
function askResolveEntry( onComplete, pblock, onNoRSS )
{
        var aborted = false;

        var rssContext = getRSSContext();
        if( rssContext == null )
        {
                if( onNoRSS != null )
                        onNoRSS();

                return;
        }

        // In preview mode, we need to be causious and listen for changes to
abort the resolution
        if( pblock != null )
        {
                function onPreviewChange()
                {
                        pblock.removeEventListener( "preview-change",  
onPreviewChange,
false );
                    aborted = true;
                }

                pblock.addEventListener( "preview-change", onPreviewChange, 
false );
        }

        if( pblock )
                pblock.innerHTML = "Correlating page to an RSS article. Please
wait...";

        var reader = lookupService( "reader" );
        reader.askResolveEntryId(       rssContext,
                                                                function( 
entryId )
                                                                {
                                                                        if( 
aborted == true )
                                                                                
return;

                                                                        if( 
pblock != null )
                                                                                
pblock.removeEventListener( "preview-change",
onPreviewChange, false );

                                                                        if( 
entryId == null )
                                                                        {
                                                                                
if( onNoRSS != null )
                                                                                
{
                                                                                
        onNoRSS();
                                                                                
}
                                                                                
else
                                                                                
{
                                                                                
        if( pblock != null )
                                                                                
                pblock.innerHTML = "This page does not map to an RSS
article";
                                                                                
        else
                                                                                
                displayMessage( "This page does not map to an RSS
article" );
                                                                                
}
                                                                                
return;
                                                                        }

                                                                        
onComplete( reader.lookupEntry( entryId ) );
                                                                }
                                                                );
}

@Blair: please note that there is a bug related to async nouns: If the
nouns does not return any suggestions then between the return and the
first aync callback the display goes black as if they are not
suggestion (when in reality the noun is looking for suggestions). I am
new to ubiquity: where should I report these kinds of issues?

Thank you,
Edwin


On Jan 20, 8:05 pm, Blair McBride <[email protected]> wrote:
> There's a "preview-change" event fired that you can listen to, to see
> when you should bail-out of an asynchronous ajax call.
>
> Or you could use the APIs provided:
>
>    CmdUtils.previewAjax()
>    CmdUtils.previewGet()
>    CmdUtils.previewCallback()
>
> They're documented 
> here:https://ubiquity.mozilla.com/hg/ubiquity-firefox/raw-file/release-0.1...
>
> The source code of those functions is also there, which should help with
> figuring out how to get it working.
>
> Of course, this system isn't ideal, and hopefully will be improved on in
> the future.
>
> - Blair
>
> On 21/01/2009 1:34 AM, Alberto Santini wrote:
>
> > In preview method I have been doing some "long" jQuery process, adding
> > results to pblock.innerHTML.
>
> > If I type new characters or I delete old ones while the old preview is
> > not completely rendered, it happens I see the results of the previous
> > preview are mixed with the new ones.
>
> > pblock.innerHTML = "" is not enough at the start of the preview
> > method.
>
> > How to clean correctly the preview?
>
> > Thanks in advance,
> > Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to