Issue with autoRender; Input field values cleard

2 views
Skip to first unread message

Julian

unread,
Oct 8, 2009, 5:36:19 AM10/8/09
to PURE - JavaScript Templates Engine
When I try to Render the data into a form for validation purposes,
the autoRender() method clears the values of all the input fields
within the selected form. How do I avoid this? I would really
appreciate if some one could help out with a solution or workaround
for this issue.

Thanks

Tchvil

unread,
Oct 8, 2009, 5:48:17 AM10/8/09
to PURE - JavaScript Templates Engine
Recently we added a default attribute for input, may be this is the
cause.

Can you provide a small working example in an html page with:
* the html
* the JS code
* some hard coded JSON data

Thanks for reporting the issue,
Mic

Julian Leonardo

unread,
Oct 8, 2009, 6:30:09 AM10/8/09
to Pure-Unobtrusive...@googlegroups.com
I noticed this issue with both, Pure v1 and Pure V2

Java SCRIPT
===========================================================

var response = {"message":null,"list":null,"validation":{"subject":"you must specify a subject"}}

$("#PostIdea").autoRender(response.validation);

HTML
================================================
<form action="/Idea/Post" id="PostIdea" method="post">
        <fieldset>
            <legend>Fields</legend>

            <p>
                <label for="subject">subject:</label>
                <input id="subject" name="subject" type="text" value="" />
                <span class="subject">validatin message</span>
            </p>
            <p>
                <label for="contents">contents:</label>
                <textarea cols="20" id="contents" name="contents" rows="2" style="width:500px; height:250px"> </textarea>
               <span class="contents">validatin message</span>
            </p>
           <p>
                <label for="contents">Tags:</label>
                <input id="tags" name="tags" type="text" value="" />
            </p>
            <p>
                <input type="submit" value="Post" onclick="return AjaxCall( 'http://www.vmiworking.com/Idea/Post' , 'PostIdea()', $('#PostIdea').serialize(), 'POST' )"  />
            </p>
        </fieldset>
</form>

Mic Cvilic

unread,
Oct 8, 2009, 4:20:09 PM10/8/09
to Pure-Unobtrusive...@googlegroups.com
I'm missing something probably.
Here is the source of the page I tried.
http://friendpaste.com/15yAQJpKI0YdOPXorTmn15

It all looks normal to me.
Please modify the source to show and describe the problem.
Cheers,

Mic

Julian Leonardo

unread,
Oct 8, 2009, 11:35:46 PM10/8/09
to Pure-Unobtrusive...@googlegroups.com
I made few changes to the code (http://friendpaste.com/15yAQJpKI0YdOPXorTmn15), this should probably reflect the issue. I noticed when the value is hard coded, the the hard coded value is not cleared. but if you enter values into input the fields, they are cleared. 

Thanks,
Julian

Tchvil

unread,
Oct 9, 2009, 9:40:23 AM10/9/09
to PURE - JavaScript Templates Engine
Ok, I understand now.
The form is recreated empty each time autoRender runs as there's no
data available for the field.
If you want to keep the form full with data, you should receive the
data back from the server.

Or if not possible, you can parse the form with JS, and pass back this
data to the JSON before running autoRender again.
Like at http://friendpaste.com/15yAQJpKI0YdOPXorTmn15

Cheers,
Mic

Julian Leonardo

unread,
Oct 12, 2009, 1:31:28 AM10/12/09
to Pure-Unobtrusive...@googlegroups.com
That makes sence. I get it now. 

Thanks,
Julian
Reply all
Reply to author
Forward
0 new messages