This is a migrated thread and some comments may be shown as answers.

how to override function of telerik javascript type at the right time

1 Answer 343 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rafe
Top achievements
Rank 1
Rafe asked on 22 Sep 2015, 10:53 AM

Greetings, if I want to augment the functionality of one of the Telerik javascript "classes", is there a proper way to override a function such that my change will be applied after the initial Telerik js declarations/file references, but before the $create() function calls which use the classes that are being modified?

For instance, I'd like to tweak the "initialize" function in the WebServiceRenderingManager class. So at some point after WebServiceRenderingManager is declared by the Telerik js script I want to update the prototype for it: 

$(function () {
    var $tsr = Telerik.Web.UI.Scheduler.Rendering;
    var $wsrm = $TSR.WebServiceRenderingManager;
    $wsrm.prototype.initialize = function () {
        // my custom code would go here
        $tsr.WebServiceRenderingManager.callBaseMethod(this, 'initialize');
    };
});

Is there a standard way/place to include my code above so that it will run after the initial WebServiceRenderingManager prototype is defined, but before the client-side code executes that initializes the control instances ($create(Telerik.Web.UI.RadScheduler, {...});)? Is there a best practice for this? 

Btw, I only need to do this for a particular aspx page, not globally for my entire site.

Thanks in advance!

 

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 25 Sep 2015, 06:33 AM
Hello,

All you need to do is put the code on the page in the script tag as for example in the code below:
<script type="text/javascript">
    var $ = $telerik.$;
 
    $TSR = Telerik.Web.UI.Scheduler.Rendering;
    $TSR.WebServiceRenderingManager.prototype.initialize = function() {
        alert(1);
        this._isWCFService = this._settings.get_path().endsWith("svc");
        this._isWebApi = this._settings.get_path().startsWith("api");
        $TSR.WebServiceRenderingManager.callBaseMethod(this, 'initialize');
    }
</script>


Regards,
Plamen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Rafe
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or