Code that uses MicrosoftAjax.js stops working after compression (?)

Sep 23, 2009 at 3:12 AM

I have the following Asp.Net MVC code (see below).

If i compress "MicrosoftAjax.js" on its own with no other js files (whilst still including all other non-compessed required files), the code stops working.

Does anyone know why this might be happening?

Many thanks for any help,

Jon

 

This is generated by Asp.Net MVC -->

        <tr>
<td>
<img alt="Perfume" src="./content/thumbdoesntexist.png" />
</td>
<td>
Perfume
</td>
<td class="actions edit">
                <a href='/Product/97e8f0df-fb2b-479a-835b-9c870003b4d5/Edit'>
<img src="../../Content/Edit.png" alt="Edit" /></a>
</td>
<td class="actions delete">
<a href="/Product/97e8f0df-fb2b-479a-835b-9c870003b4d5" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, confirm: 'Are you sure you wish to delete this?', httpMethod: 'Delete', updateTargetId: 'divProductList', onBegin: Function.createDelegate(this, beginProductList), onFailure: Function.createDelegate(this, failureProductList), onSuccess: Function.createDelegate(this, successProductList) });"><img alt="Delete this?" src="../../Content/Delete.png" /></a>
</td>
</tr>

 

From -->

 

<%
            foreach (Product item in Model)
            {
%>
        <tr>
            <td>
                <%=Html.Thumbnail(item)%>
            </td>
            <td>
                <%=Html.Encode(item.Title)%>
            </td>            
            <td>
                <a href='<%=Url.Action("Edit", new {id = item.Id})%>'>
                    <img src="../../Content/Edit.png" alt="Edit" /></a>
            </td>
            <td>
                <%=
                    Ajax.ImageActionLink(
                        "../../Content/Delete.png",
                        "Delete this?",
                        "Destroy",
                        "Product",
                        new {id = item.Id},
                        new AjaxOptions
                            {
                                Confirm = "Are you sure you wish to delete this?",
                                HttpMethod = "Delete",
                                UpdateTargetId = "divProductList",
                                OnBegin = "beginProductList",
                                OnSuccess = "successProductList",
                                OnFailure = "failureProductList"
                            },
                        null)%>
            </td>
        </tr>
        <%
            }%>

 

<script type="text/javascript">

        function beginProductList(args) {
            // Animate
            $('#divProductList').fadeOut('normal');
        }

        function successProductList() {
            // Animate
            $('#divProductList').fadeIn('normal');
        }

        function failureProductList() {
            alert("Could not retrieve product list.");
        }

    </script>

Sep 23, 2009 at 3:15 AM

By the way....

Works:

<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/MicrosoftAjax.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/MicrosoftMvcAjax.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery-1.3.2.min.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.validate.min.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/xVal.jquery.validate.min.js")%>"></script>

Broken:

<script type="text/javascript" src="<%= ResolveUrl("~/Scripts/JavaScriptFinal.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/MicrosoftMvcAjax.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery-1.3.2.min.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/jquery.validate.min.js")%>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/Scripts/xVal.jquery.validate.min.js")%>"></script>

The symptom is that the inline onclick event doesnt get fired - the destination of the link tag is visited instead...

Cheers,

Jon

 

Coordinator
Oct 14, 2009 at 7:27 AM

Hi Jon - is this still not working / busted?

I've haven't tried compressing/minifying MicrosoftAjax.js / MicrosoftMvcAjax.js

 

Also, looking at your second post, the one that 'works' includes MicrosoftAjax.js ... but not the broken one .. are u sure that the stuff u're trying to do (eg. OnClick event stuff) is not dependant upon the MicrosoftAjax.js file?