kattunga / IWBootstrapFramework

Intraweb Bootstrap 3 Framework for Delphi
http://kattunga.github.io/IWBootstrapFramework
MIT License
98 stars 42 forks source link

Problem with async update TIWBSText Content in RawText mode #10

Closed tdzieciol closed 8 years ago

tdzieciol commented 8 years ago

Plase drop on form TIWBSText component, set RawText:=True and fill Lines with simple unorder list html code. Next drop on form TIWBSButton and in OnAsyncClick event modify TIWBSText.Lines property (i.e. add option). After button click page is not updated. I think it's work properly in version before Oct 8, 2015

kattunga commented 8 years ago

Fixed in latest commit. Take care to replace wwwroot/iwbs/iwbs.js with latest one. Please test it.

tdzieciol commented 8 years ago

TIWBSText component is updated properly. But I have another problem. I add own script in WebApplication.CallbackResponse.AddJavaScriptToExecute to do something with updated component (i.e. reinitialize updated data table). Unfortunately, my script is executed before updating the content of the component and is working on its outdated content. Is there any way to solve this problem?

kattunga commented 8 years ago

There are several ways to correctly approach it, (but you need to download latest commit):

a) Put script in the Script property of the component. This script will be rendered inside the tag after the html so any change in object or script will be automatically reflected when anything change. You also have a ScriptParams property that replace values in string. (See bootstrap tables on Demo) .

b) Execute "WebApplication.CallbackResponse.AddJavaScriptToExecute" on OnAsyncRender event of the control. This event happens after component is updated.

c) If you have several controls in you page, for example select inputs, and you want to apply same javascript to all of them (refresh some third party plugin) yo can use global hook "gIWBSOnRenderAsync". See BOOTSTRAPSELECT in ServerController.pas on Demo.

Regards

tdzieciol commented 8 years ago

Thanks for your suggestions. You can close this issue. Regards

kattunga commented 8 years ago

Please, if you can, I'll appreciate if you first test the tree ways I suggest to you and let me know if they all works correctly. I prefer to close this issue after that.

tdzieciol commented 8 years ago

I checked all three ways and work for me properly. For global hook I prefer solutions based on a list of procedures that I can register individually instead of a single procedure. This makes it easier to build the program in a modular way.

kattunga commented 8 years ago

For global hook I prefer solutions based on a list of procedures that I can register individually

Could you explain me that a little more? May be an example?