Maybe you need to iterate through the class elements. See this:
https://stackoverflow.com/questions/4735342/jquery-to-loop-through-elements-with-the-same-class
On Thursday, 16 May 2019 23:58:28 UTC+1, Vlad wrote:
>
> Just to clarify:
>
> the following works perfect for one field by ID (decrypts it back):
> var encodedDescription = $("#CurrentCartDescription").text()
> $("#CurrentCartDescription").html(atob(encodedDescription));
>
> However, when I try to do it for a bunch of fields at once using class
> (instead of id), it doesn't work - doesn't touch the values:
>
> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>
> I am sure I am missing something basic... Greatly appreciate suggestions -
>
> On Thursday, May 16, 2019 at 6:54:14 PM UTC-4, Vlad wrote:
>>
>> I had no clue about it - I mean never heard the terms :)
>>
>> Thank you very much for point to the direction. After some googling, it
>> is almost working.
>>
>> Encoding is just fine (using btoa).
>>
>> When I read it back and want to decode - it's not yet behaving right. I'm
>> suspecting my javascript is a problem.
>>
>> There is a bunch of fields which now have encrypted values (class
>> 'EncodedDescriptionField'), and I am trying to use the following to reclaim
>> the original values:
>>
>>
>> $(".EncodedDescriptionField").html(atob($(".EncodedDescriptionField").text()));
>>
>> What am I doing wrong? (It doesn't change the values - they remain as
>> they are, encrypted)
>>
>> On Thursday, May 16, 2019 at 5:35:39 PM UTC-4, João Matos wrote:
>>>
>>> Have you considered base64 encoding/decoding?
>>>
>>> quinta-feira, 16 de Maio de 2019 às 20:43:58 UTC+1, Vlad escreveu:
>>>>
>>>> I have the following javascript in the view:
>>>>
>>>> var id = $('#CurrentCartId').text();
>>>> var description = $(this).text();
>>>> var url='{{=URL('cart','description')}}';
>>>> url += '/' + id + '/';
>>>> url += description;
>>>> ajax(url,[],':eval');
>>>>
>>>> the reason I use url+= to pass parameters instead of using args in the
>>>> URL helper is because the parameters are coming from the html itself -
>>>> they
>>>> are not known in the controller py.
>>>>
>>>> now the problem is that it changes the description and I have no way to
>>>> recover its original value. for example, when description is "askjdf d
>>>> dka;lskdj 3838&^&%$#@ ((alksjdf__ - ))" (just a randomly typed string in
>>>> this case), it comes out as "askjdf_d___dka_lskdj__3838_____". Obviously,
>>>> it needs to do this conversion in order to pass the parameter, but I need
>>>> to be able to recreate the original string, entered by the user.
>>>>
>>>> Is there a better way of doing this? I.e. a better way of passing a
>>>> parameter in a way that it could be "recreated" and stored in the
>>>> database
>>>> exactly as typed by the user?
>>>>
>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/d0d5cc0b-1a55-45ad-a8c3-caeefa695d3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.