dalekjs / dalek

[unmaintained] DalekJS Base framework
MIT License
695 stars 63 forks source link

setValue() doesnt work #130

Closed burt202 closed 9 years ago

burt202 commented 10 years ago

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 10 years ago

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

burt202 commented 10 years ago

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 10 years ago

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.

rodneyrehm commented 10 years ago

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

burt202 commented 9 years ago

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?

asciidisco commented 9 years ago

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.

asciidisco commented 9 years ago

setValue works in 0.0.9.