dalekjs/dalek

setValue() doesnt work

burt202 opened this issue · 7 comments

Hi, I know this is sort of a duplicate of the closed issue #77 , but I still get the error {'0': undefined} when trying to use setValue to clear an input. In #77 it says it has been fixed in canary, I am using v0.0.8 so should I expect this to be fixed in this build?

Also what version is the .clear method going to be added (mentioned in #111) for just running in phantomJS?

Thanks in advance

mdix commented

Hi,

can just help with a workaround for that one using unicode:

.type('#inputName', '\uE003\uE003\uE003\uE003\uE003\uE003\uE003\uE003\uE003\uE003\uE003\uE003')

Best
Marc

Cool. I will give this a go. Can you explain what its actually doing though for myself and anyone else reading this thread? Cheers

mdix commented

Hi,

thanks for your time. Snap, totally missed that. Sorry! Follow up the explanation:

.type() selects #inputName and appends a char sequence. It's also possible to use unicode. This enables you to use keys that are pressable, but have no text representation. U+E003 is the unicode equivalent for a backspace. So, the field is selected, the cursor is put at the end (appending) and the backspace is pressed multiple times.

If you plan on using it, it might make sense to prepare a var for this:

var multipleBackspaces = new Array(50).join('\uE003');

And use it like:

.type('#inputName', multipleBackspaces)

Best
Marc

Edit: Updated the example. Much better, thanks @rodneyrehm.

simple string repeat: (new Array(50).join('\uE003'))

I have to admit, the above suggestions both feel more like hacks than a solution to the issue. Any news on when .clear might be added?

I´ll try to add clear() in the 0.0.9 release. Which will be there before Skaro is ready, but I can't exactly tell when this will be.

setValue works in 0.0.9.