UI only rich text field does not return value

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hi using this skuid.$M('model').data[0].ui_richtext  always returns undefined. Other types of UI only fields work fine using this syntax. Any pointers?
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Looks like that should work.

If it returns undefined, then a field by that name isn't in the model. When you run skuid.$M('model').getFirstRow() in the console, does the object include ui_richtext?

Generally, using skuid.$M('model').getFirstRow().ui_richtext would be preferable, since it's always better to use a documented method than an undocumented one, but they do exactly the same thing.
(Edited)
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
How do I get to the field using jQuery? $("#uifieldid") .val() does not work.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
The code above doesn't save the value, it just updates the model, which will then have unsaved changes. You can perform a separate save action if that's what you want.

Why access the value with jQuery when you can get to it with the skuid api instead?

If you really want to try jQuery, you can try $("#uifieldid") in the console and see what your options are.
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
The problem is I cannot get to it in Skuid. I tried to add
skuid.$M('NewContactResult').updateData(field.row,field.id,value,{initiator_id:field._GUID});
after:
skuid.ui.fieldRenderers[field.metadata.displaytype]["edit"](field,value);

It says Model NewContactResult has unsaved changes and asks me to save it first. Now I'm going back to my original requirement. I don't want to save the model yet. I want user to be able to click on the Save themselves.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
J... there was a typo in the code I gave you.

You don't want to updateData() - which is a query.

You want to updateRow().

Add this line to your field renderer instead:

field.model.updateRow(field.row,field.id,value,{initiator_id:field._GUID}); 
If the model you want to update isn't the field's model, you can also use
 skuid.$M('NewContactResult').updateRow(field.row,field.id,value,{initiator_id:field._GUID});
(Edited)
Photo of Janet

Janet

  • 486 Points 250 badge 2x thumb
Thanks! That did the trick.