ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Determine moment when all lookup fields are loaded
Title:
B
I
{code}
?
Hi! Is there a callback or another way to determine if a Lookup field has loaded its data (and know field name)? Or, is there any way to be sure that every lookup on page has loaded its data? onreadystatechange() does not seem to be useful here. The problem is, on a form with multiple lookup/multilookup fields user clicks submit button before the fields are even loaded, and posts empty data causing validation errors, data loss etc. The only way I see it now is passing field name as parameter, and checking it in handling ajaxComplete(), but that seems terribly wrong.
Save Changes
Cancel
whatnoise
asked at 09 Jul 2014
that shouldn't be a problem, the value is set in a hidden html field before the caption is loaded, the lookup is loading the caption, the value is there already and it's being passed to the server to get the caption you can experiment with the demo, on this page: http://localhost/AwesomeMvcDemo put a Thread.Sleep in ChefLookupController.GetItem and try editing/creating a few meals ( in the ajaxlist on the bottom )
at 09 Jul 2014
Omu
Sorry, but just to be sure: is this actual for MultiLookupfield too? Seems like ML consists of (a) hidden input with value="[1,2,3,4]", (b) a checkbox input with the same name and (c) multiple hidden inputs with actual values (keys). As the control starts to load, there's only (a) input and it's disabled (should it be?) ,so if user submits a form while control is loading, nothing is submitted. If we manually enable this control, the default MVC model binder cannot understand the brackets [] anyway. So only after items have been loaded, multilookup can produce valid submit values?
at 21 Aug 2014
whatnoise
it works for the multilookup as well, you can try it in the demo solution, in MealsMultiLookupController.GetItems add Thread.Sleep(5000) before return Json, build it and on homepage try editing items in the ajaxlist on the bottom of the page, open the edit popup for an item and wait for it load, edit the Meals field and click Ok instantly, you'll notice that the values in the ajaxlist are updated correctly; atm there will be confusion if you open the edit form and hit ok instantly before the multilookup is loaded, but we will fix this for the next release
at 28 Aug 2014
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK