What is the recommended approach for clearing data out of a

Posted by jsniemi79 on 11-Nov-2014 16:14

If I view a record and go back to my list on a master - detail setup, what is the best way to clear the fields so I get new values when i select my next record?

Posted by Orchid Corpin on 13-Nov-2014 16:56

For selector you can use:

$("#fieldName option[code='S']").attr("selected", true);     < --- If using code as identifier

$("#fieldName option[value='Small']").attr("selected", true);    < ---- If using value as identifier

Regards,

Orchid

All Replies

Posted by Orchid Corpin on 11-Nov-2014 16:33

Hi,

Is this a Mobile-Web version or Mobile (with the mobile builder)?

Regards,

Orchid

Posted by jsniemi79 on 11-Nov-2014 16:35

It will be a hybrid built through the the mobile designer.

Posted by Orchid Corpin on 11-Nov-2014 17:22

Hi,

I have a sample app creation document here that may help you to give a detailed info in creating navigation page.

You can see it in page 26. (see attachement)

Hope this may help.

Regards,

Orchid

Posted by jsniemi79 on 11-Nov-2014 18:10

Hi Orchid,

Thank you for the document.  I have that working fine in my application.  What I would like to know is after I have viewed the details and I click back, I am selecting another record and going into those details instead of the logout like your example.  If I do this, the details from the first record I viewed are still displayed instead of the details from my new record.

I have the same scenario if I say create a new task.  It navigates me correctly where I want and creates the record, but if I immediately choose to crate another new task, it still has all the values from my last task in the fields.

Is there a function I can call to clear everything or do I need to write the javascript to clear out every field on each page when I leave?

Let me know if any of these doesn't make sense.

Thanks again

Posted by Orchid Corpin on 12-Nov-2014 10:48

I see, i thought it was navigating into another record. You can clear it via Jquery Code.

1. Go to your Data Source of your Page.

2. Click on "DATA SOURCE EVENTS"

3. Select your data source and "Add Events"

4. Event type would be "Success", action is "Run Javascript" and use the below code. If you already have Success event just add the below code on it.

$("input").val("");
$("textarea").val("");

Save and test.

Regards,

Orchid

Posted by jsniemi79 on 13-Nov-2014 15:19

Hi Orchid,

I tried this code and am not having any luck getting the fields to clear out.

Here is the javascript

Here is the order I am running them in on my create datasource.  It is creating the record perfectly and taking me to the page I want, but the fields are still populated when I return. Can you see something I have wrong?

Posted by Orchid Corpin on 13-Nov-2014 15:38

try having "#" before the field names like $("#txt_subject").val(""); - this is for individual field.

BUT...

If you want to clear ALL "input" and "textareas" HTML elements regardless their IDs and Names so use $("input").val(""); or $("textarea").val(""); - without "#" represents HTML elements

Regards,

Orchid

Posted by jsniemi79 on 13-Nov-2014 15:45

That worked to clear out my fields.  Thank you!!

Can you tell me how to set the value on a selector?  I want to reset it to always be the default value.

Posted by Orchid Corpin on 13-Nov-2014 16:56

For selector you can use:

$("#fieldName option[code='S']").attr("selected", true);     < --- If using code as identifier

$("#fieldName option[value='Small']").attr("selected", true);    < ---- If using value as identifier

Regards,

Orchid

Posted by jsniemi79 on 14-Nov-2014 09:40

I tried using the value to set this to a default, but it doesn't appear to be working.  I am also having trouble getting a label to be cleared out.  See below for the information.

Selector is menu_priority

On Success of my create service this is run

After this runs, the input and textarea are cleared, but the label and the selector are not set as I hoped.

Posted by Orchid Corpin on 14-Nov-2014 10:39

For picklist: changed "#" into element name because when I inspect element on it, it has different value on its ID. Change the "value" also into :contains(), values in the element are shown as ID and not the label. See image below.

$("select[name='select_name'] option:contains('Hot')").attr("selected", true);  

For Label: changed the "#" into an element name as well and use .text() instead of .val(). In JQuery .val() is for use for elements of something you can input.

$("div[name='lbl_description_txt']").text("Hello World");


Regards,

Orchid

This thread is closed