Partial Updates for Gadget ?


I just yesterday started trying out gadget development and did the tutorial for a QuickChat ( and it's all nice and working, however the ajax update on 5 seconds is a bit anoying since it updates the entire view and not only the messages. If i start typing in the message box for a new message it will be cleared when the gadget gets refreshed.

I found a small gadget api reference ( but there is no hint about how to do partial updates for a gadget like partial updates in MVC.

Does anyone know how to do this ?

Dec 16, 2010 10:03

I found this old script that I think takes care of only updating the messages. QuickChat.js:

(function($) {
    quickchat = {};
    quickchat.init = function(e, gadgetContext) {
        // Reloads the gadget if it is visible
        var reload = function() {
            if (gadgetContext.isVisible()) {
                // Using the uses the gadet's ajax handler brings 
                // features such as the ajax loader and error handling 
                var routeValues = { action: "Messages" }
                var actionUrl = gadgetContext.getActionPath(routeValues);
                    url: actionUrl,
                    dataType: "html",
                    success: successHandler

        // Updates the messages div with new content retrieved 
        // by the ajax request
        var successHandler = function(data) {
            var chatMessages = $(".messages", gadgetContext.element);

        // start reloading the messages at an interval
        setInterval(reload, 5000);


Edited, Dec 16, 2010 10:18

Looks promising but (var gadgetInstance = gadgetContext.instance;),
Gets a null value wich breaks on isVisible function.

anything im missing ?

Dec 16, 2010 10:31

It seems the code predated the release version and some things have changed. I updated it a bit and it might work better now.

Dec 16, 2010 10:46

It ain't breaking now but i can't really se any ajax updates either, it's like the 5 sec intervall ain't running.

Firebug in Firefox is not picking upp any ajax calls, not in the net tab or console tab.

Any Clues ?

Dec 16, 2010 10:56

What happens if you remove the isvisible check? This really isn't a good way to debug old code ;)

Dec 16, 2010 10:59

Well now it starts refresh every 5 sec, although now i get 500 errors so i gota figure that one out now.

Got it working now but my entire gadget replaced the orginal message list and now is updated. How is your Messages action setup ?

Made a new partial view for the message part and that is working nice now, only updates that part too :)

Edited, Dec 16, 2010 11:01
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.