Re-enable a datetime picker that was disabled by a Rule

  • 6 October 2016
  • 6 replies
  • 11 views

Badge +6

Hey guys,

I'm using the following jQuery to re-enable all controls within a panel, that was initially disabled by a Form Rule:

NWF$('.form2 *').prop('disabled'false);

Everything gets re-enabled as expected, EXCEPT the datetime picker:

192946_pastedImage_1.png

The calendar image remains opaque and nothing happens when I click on it, as if no event is associated with it...

PS: the actual input control of the datetime picker is enabled correctly, it's just the picker that doesn't seem to work!

Does anyone know how to force it to be enabled, or at least re-attach the calendar popup event??


6 replies

Userlevel 5
Badge +14

the most probably the icon doesn't have property 'disabled' so it's not found by your selector.

you will have to investigate DOM structure to find out what property controls icon's functionality.

however, I quite don't understand the approach. you first disable controls by a rule and then leverage in some javascript how to enable them.

why not to write rule's formula so that it disables control only when needed and leave them enabled in other cases?

Badge +6

The rules for enabling/disabling the specific panel were quite complex, that's why I opted to use JS instead of the regular form rules...

It is strange however that ALL other controls have been enabled, but the datetimepicker does not seem to trigger the popup event! Is there no way to re-attach the event handler manually?

Just FYI, here's the DOM structure:

192951_pastedImage_1.png

I can easily remove the cursor and opacity styles, the only issue seems to be the event not triggering!

I can only imagine it's being added/removed by the Nintex Form using jQuery UI?

Userlevel 5
Badge +14

whatever are your reasons resp. however the rule is complex I wouldn't do it that way!

rules are reevaluated and reapplied automatically on various events/changes, I'm quite sure you will not be able to catch all such event's so that you can reapply you javascript code.

however, if you insist on that following worked for me for single date picker

NWF$('#'+dt).closest('div').find('img').prop('disabled','disabled')
NWF$('#'+dt).closest('div').find('img').removeProp('disabled')

so, the img/icon recognizes disabled property.

I do not know why it's not accepted with your selector. maybe it evaluates presence of disabled differently (prop need to be removed), but likely it might as well be due to reasons I mentioned above.

Badge +6

Hey Marian,

Thanks for your suggestions, I really hoped the removeProp command would work!

It does work if I disable the panel manually (which might also be a valid alternate solution btw), but it doesn't work if it has been disabled by the form rule...

For some reason the Nintex form changes the mimeType of the image from GIF File to Gif Image, and probably does something else to affect the event handler as well!

Userlevel 5
Badge +14

if you disable/unconfigure those complex rules, does this happen too?

Badge +6

Hey Marian,

The problem with the missing event handlers only shows up when I manually re-enable a datetime picker that was previously disabled by a form rule...

Anyway, since I couldn't find a solution for locking/unlocking from Form rules + JS, I decided to only do the locking from JS! So whenever I disable the datetime picker by setting its disabled prop to false and then re-enable it, works like it should happy.png

I'll mark your original answer as correct, thanks for your time!

Reply