Uncaught TypeError: Property 'tmpl' of object #Object is not a function

Hi,

I am having issues with MiniProfiler running on our .Net mvc system. I can get it working fine in stand alone solutions, but when I try to integrate it with our main work project I hit the error in the title bar.

The point at which things blow up is in jquery.tmpl.js :

if (fn) {
            // Build the hierarchical content to be used during insertion into DOM
            newItem.tmpl = fn;
            newItem._ctnt = newItem._ctnt || newItem.tmpl(jQuery, newItem);

at this point typeof fn is object. fn and therefore newItem.tmpl contains the following html:

<script id="timingTemplate" type="text/x-jquery-tmpl">

  <tr class="{{if timing.IsTrivial }}profiler-trivial{{/if}}" data-timing-id="${timing.Id}">
    <td class="profiler-label" title="{{if timing.Name && timing.Name.length > 45 }}${timing.Name}{{/if}}">
      <span class="profiler-indent">${MiniProfiler.renderIndent(timing.Depth)}</span> ${timing.Name.slice(0,45)}{{if timing.Name && timing.Name.length > 45 }}...{{/if}}
    </td>
    <td class="profiler-duration" title="duration of this step without any children's durations">
      ${MiniProfiler.formatDuration(timing.DurationWithoutChildrenMilliseconds)}
    </td>
    <td class="profiler-duration profiler-duration-with-children" title="duration of this step and its children">
      ${MiniProfiler.formatDuration(timing.DurationMilliseconds)}
    </td>
    <td class="profiler-duration time-from-start" title="time elapsed since profiling started">
      <span class="profiler-unit">+</span>${MiniProfiler.formatDuration(timing.StartMilliseconds)}
    </td>

  {{if timing.HasSqlTimings}}
    <td class="profiler-duration {{if timing.HasDuplicateSqlTimings}}profiler-warning{{/if}}" title="{{if timing.HasDuplicateSqlTimings}}duplicate queries detected - {{/if}}{{if timing.ExecutedReaders > 0 || timing.ExecutedScalars > 0 || timing.ExecutedNonQueries > 0}}${timing.ExecutedReaders} reader, ${timing.ExecutedScalars} scalar, ${timing.ExecutedNonQueries} non-query statements executed{{/if}}">
      <a class="profiler-queries-show">
        {{if timing.HasDuplicateSqlTimings}}<span class="profiler-nuclear">!</span>{{/if}}
        ${timing.SqlTimings.length} <span class="profiler-unit">sql</span>
      </a>
    </td>
    <td class="profiler-duration" title="aggregate duration of all queries in this step (excludes children)">
      ${MiniProfiler.formatDuration(timing.SqlTimingsDurationMilliseconds)}
    </td>
  {{/if}}

  {{each page.CustomTimingNames}}
    {{if timing.CustomTimings && timing.CustomTimings[$value]}}
      <td class="profiler-duration" title="aggregate number of all ${$value.toLowerCase()} invocations in this step (excludes children)">
        ${timing.CustomTimings[$value].length} ${$value.toLowerCase()}
      </td>
      <td class="profiler-duration" title="aggregate duration of all ${$value.toLowerCase()} invocations in this step (excludes children)">
        ${MiniProfiler.formatDuration(timing.CustomTimingStats[$value].Duration)}
      </td>
    {{else}}
      <td colspan="2"></td>
    {{/if}}
  {{/each}}

  </tr>

  {{if timing.HasChildren}}
    {{each timing.Children}}
      {{tmpl({timing: $value, page: page}) "#timingTemplate"}}
    {{/each}}
  {{/if}}

</script>

If you examine the content as pure text it is script, but if I enter a line to evaluate it into a function then the MiniProfiler results show, but the steps are identified as [Object Object] which is less than useful.

If anyone can help with this I would be very grateful.

I have fixed this. It was being caused by DevExpress’s scripts. I moved these to the very top of the Site.Master and it seemed to fix it.