I have a very simple grid that I am adding a runtime (e.g. user clicks a button to add this grid). The OnConnected event of my hub never gets fired. Interestingly when I move the same code to the $(document).ready(function() it works fine. It appears the issue is with binding the client to the hub dynamically.
My code, the values of chat and hubStart are valid.
$(
'.controls'
).on(
'click'
,
'img'
,
function
(e) {
loadLiveEvents()
}
function loadLiveEvents() {
var connection = $.connection;
var chat = connection.messageHub;
// Start the connection.
var hubStart = $.connection.hub.start().done(function() {});
var dataSource = new kendo.data.DataSource({
type: "signalr",
autoSync: true,
schema: {
model: {
id: "ID",
fields: {
"ID": { type: "number" }
}
}
},
transport: {
signalr: {
promise: hubStart,
hub: chat,
server: {
read: "readbasic",
update: "sendToGrid",
create: "sendToGrid"
},
client: {
read: "readbasic",
update: "sendToGrid",
create: "sendToGrid"
}
}
}
});
$("#myGrid").kendoGrid({
columns: [
{ field: "ID" },
],
dataSource: dataSource
});
}