I just started playing around with jquery widgets within my jqmodals in my mvc app.
Initially,
ajax: "/Home/EditPrintAdLine" and ajax: "/Home/AddPrintAdLine" will eventually render the same web user control which contains the element that inits the widget (field name is PrintAdLine_RunDate)
Any ideas?
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<div id="printAdLineEditDialog" class="jqmWindow"></div>
<div id="printAdDialog" class="jqmWindow"></div>
<table>
<tr><td><a id="printAdLineItem" href="#">Add a Line Item</a></td></tr>
<tr><td><a id="editPrintAdLine" href="#">Edit</a></td></tr>
</table>
<script type="text/javascript">
$(document).ready(function() {
$.widget("ui.my_widget", { _init: function() { alert("My widget was instantiated"); } });
// Add line
$('#printAdDialog').jqm({
ajax: "/Home/AddPrintAdLine",
trigger: '#printAdLineItem',
onLoad: function(hash) {
$('#PrintAdLine_RunDate').my_widget();
}
});
// Edit line
$('#printAdLineEditDialog').jqm({
ajax: "/Home/EditPrintAdLine",
trigger: '#editPrintAdLine',
onLoad: function(hash) {
$('#PrintAdLine_RunDate').my_widget();
}
});
});
</script>
</asp:Content>
Turned out to be a scoping issue.
$('#PrintAdLine_RunDate', 'printAdLineEditDialog').my_widget();
$('#PrintAdLine_RunDate', 'printAdDialog').my_widget();