Aug 04, 2014, 5:01 PM
Store's listeners fired many times
In my MVC 3 application, i want to refresh a partial View each time there is new available data. So to get these data from the server side, i'm using a componentLoader like below:
When refresh the partial view at the first time, i can see in the console that WarningsStore.Register JS function was called once but at the second time is called twice , third time is called 3 times ... This is how i defined the WarningsStore.Register JS function:
Panel lowerPanel = new Panel
{
Region = Region.South,
Layout = "fit",
ID = "WarningsPanel",
AutoScroll = true,
Loader = Html.X().ComponentLoader()
.Url(Url.Action("_warningsView"))
.Mode(LoadMode.Script)
.MessageBusDirectEvents(
new MessageBusDirectEvent()
{
Name = "Warnings.Update",
Action = "_warningsView",
Buffer = 1000,
ExtraParams = { new { containerId = "WarningsPanel" } }
}
)
.Params(new { containerId = "WarningsPanel" })
.LoadMask(l => l.ShowMask = true)
};
after getting new data from the server, i want to call some javascript functions. so i setted my partial view like below: @(Html.X().GridPanel()
.ID("WarningsGridPanel")
.EnableColumnResize(true)
.Store(Html.X().Store()
.DataSource(Model)
.Model(Html.X().Model()
.Fields(
Html.X().ModelField().Name("id"),
...
)
.Listeners(l =>
{
l.DataChanged.BroadcastOnBus = "Warnings.Register";
l.DataChanged.Buffer = 5000;
})
.MessageBusListeners(mbl => mbl.Add(new MessageBusListener { Name = "Warnings.Register", Fn = "WarningsStore.Register"}))
)
.ColumnModel(//Html.X().RowNumbererColumn().Align(Alignment.Center).Width(Unit.Pixel(30)),
Html.X().Column().Text("ID").DataIndex("id").Flex(1).Hideable(false),
...
)))
When refresh the partial view at the first time, i can see in the console that WarningsStore.Register JS function was called once but at the second time is called twice , third time is called 3 times ... This is how i defined the WarningsStore.Register JS function:
WarningsStore = WarningsStore || {};
WarningsStore.Register = function (message, id, eOpts) {...}
What can be the problem? is there many stores? am defining JS function in the wrong way?