Is there an event that fires when invalidate() is called?

Is there an event that fires when invalidate() is called?

DanSwitzer2DanSwitzer2 Posts: 21Questions: 4Answers: 0

There doesn't appear to be an event that fires when invalidate() is called.

The problem is this function alters the DOM, but there doesn't appear to be any event that fires after this method takes place.

I'm having an issue where I have an extension I wrote that adds some elements to the table to help with layout. These DOM helpers get put in place during initialization or when a new row is added.

When I use the ColReorder plugin, it calls the invalidate() method on all the rows and the content is rerendered, so the elements added are removed.

I could attach a column-reorder event for this specific use case, but I was hoping for a fix that would cover all the use cases.

Am I missing an event that does fire?

If not, any chance on getting an invalidate event() that would fire after the function has been called?

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    There isn't I'm afraid. I'm somewhat concerned about using jQuery events for things like invalidate as they are slow when used for something which can trigger a lot of them (e.g. invalid every row in the table - it would take a noticeable amount of time).

    I'm going to look into how to address that with the next major version.

    Allan

  • DanSwitzer2DanSwitzer2 Posts: 21Questions: 4Answers: 0

    @allan

    I certainly understand that.

    Could you just debounce the event, that way if it's called frequently, only the last run is actually executed?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Yes, that is one option. But then you run into possible async issues - the page might redraw before the event has been executed giving a horrible flash of incorrect content for example.

    More likely I'll offer some events which are basically Javascript callbacks with a very simple loop to spin over any listeners. No namespaces and no event objects, which should make it fast enough.

    Allan

This discussion has been closed.