Bug Tracker

Modify

Ticket #6331 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

BUG on Setting value to hidden input

Reported by: jennal Owned by:
Priority: undecided Milestone: 1.4.3
Component: manipulation Version: 1.4.2
Keywords: val Cc:
Blocking: Blocked by:

Description

I try to set a long html to a input:text, it is ok. But when I set the input to hidden, then set the same html value to it. The input gone.

Please see attach.

Attachments

test2.html Download (2.5 KB) - added by jennal 3 years ago.

Change History

Changed 3 years ago by jennal

comment:1 Changed 3 years ago by addyosmani

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to worksforme

I've tested the above bug in Safari and FireFox (latest builds) and it would appear that a few things are going on here:

  1. Your test to establish whether the value of the long piece of text/html being set to the input field value is incorrect.

Rather than checking the length of the input field itself, you want to be checking the length of $('#test').val().length instead.

This will give you a value of over 2000 rather than the value of 1 you were previously getting.

  1. Using $('#test').val() once you have set your hidden field's value, you are easily able to re-use the value set (I was able to alert the entire html/text string without any trouble at all).

Closing as this works for me. I think it was just a case of the original submission testing for attribute lengths in the wrong way.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.