Telerik MVC ScriptRegistrar duplicates javascript

I am trying to register javascript in my opinion and I seem to have a problem. On my main page below:

@(
    Html.Telerik().ScriptRegistrar()
        .OnDocumentReady(@<text>
            // Open the hidden window when the feedback-link is clicked
            $('#feedback-link').click(function(e) {
                e.preventDefault();
                $('#FeedbackWindow').data('tWindow').center().open();
            });
        </text>)
)

In my opinion, I need specific javascript, so I:

@(Html.Telerik().ScriptRegistrar().OnDocumentReady(
    @<text>
        // Upon contact selection change, update the contact sidebar summary
        $('#contactlist').change(function() {
            alert('Selected id' + $(this).val());
        });
    </text>)
)

Unfortunately, this causes my javascript view to be declared both in the MVC view and on my main page when rendering the last page. How can I get this to register only the script once?

+3
source share
1 answer

, ScriptRegistrar , . @() Razor , @{ } . @{ } script:

@{ Html.Telerik().ScriptRegistrar().OnDocumentReady(
    @<text>
        // Upon contact selection change, update the contact sidebar summary
        $('#contactlist').change(function() {
            alert('Selected id' + $(this).val());
        });
    </text>);
}

, @{ } .

+4

All Articles