Difference between Silk and Web

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference between Silk and Web

horrido
I've encountered another issue with Silk/DOMite. In Web, the following works fine...

html input
        type
: 'submit';
        value
: 'Collect Input Field Values';
        onClick
: [ self collectValues ]


collectValues
   
(('#myForm1' asJQuery get: 0) checkValidity) ifTrue: [
       
"do something"
       
^false]

The ^false short-circuits normal posting behaviour in the form.

However, Silk behaves differently...

(Silk INPUT: {'type'->'submit'. 'value'->'Okay'})
                        on
: 'click' bind: [self collectValues]

The ^false does not short-circuit normal posting behaviour. In fact, it doesn't matter whether you return true or false; it just merrily continues as normal.

When I look at #on:bind:, it shows a significant difference from TagBrush's #onClick:...

on: aString bind: aBlock
   
self element addEventListener: aString block: aBlock useCapture: false


onClick
: aBlock
   
self asJQuery bind: 'click' do: aBlock

Web is using JQuery. Could this explain the difference? Why can't I short-circuit normal posting behaviour in DOMite?


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Difference between Silk and Web

Herby Vojčík
The `return false` is easy, but the really correct way to do this.
See
http://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false 
and
http://stackoverflow.com/questions/18971284/event-preventdefault-vs-return-false-no-jquery.
So it seems you should do

   [ :e | self collectValues ifFalse: [ e preventDefault. false ]]

or similar to do thing properly (the '. false' is just for backward
compatibility / IE-safety, maybe it is not needed).

Richard Eng wrote:

> I've encountered another issue with Silk/DOMite. In Web, the following
> works fine...
>
> ||
> html input
> type:'submit';
> value:'Collect Input Field Values';
> onClick:[selfcollectValues ]
>
>
> collectValues
> (('#myForm1'asJQuery get:0)checkValidity)ifTrue:[
> "do something"
> ^false]
>
> The ^false short-circuits normal posting behaviour in the form.
>
> However, Silk behaves differently...
>
> ||
> (SilkINPUT:{'type'->'submit'.'value'->'Okay'})
> on:'click'bind:[selfcollectValues]
>
> *The ^false does not short-circuit normal posting behaviour. In fact, it
> doesn't matter whether you return true or false; it just merrily
> continues as normal.*
>
> When I look at #on:bind:, it shows a significant difference from
> TagBrush's #onClick:...
>
> ||
> on:aString bind:aBlock
> selfelement addEventListener:aString block:aBlock useCapture:false
>
>
> onClick:aBlock
> selfasJQuery bind:'click'do:aBlock
>
> Web is using JQuery. Could this explain the difference? Why can't I
> short-circuit normal posting behaviour in DOMite?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Difference between Silk and Web

Herby Vojčík


Herby Vojčík wrote:
> The `return false` is easy, but the really correct way to do this.
s/the really/not really the/

> See
> http://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false
> and
> http://stackoverflow.com/questions/18971284/event-preventdefault-vs-return-false-no-jquery.
> So it seems you should do
>
> [ :e | self collectValues ifFalse: [ e preventDefault. false ]]
>
> or similar to do thing properly (the '. false' is just for backward
> compatibility / IE-safety, maybe it is not needed).
>
> Richard Eng wrote:
>> I've encountered another issue with Silk/DOMite. In Web, the following
>> works fine...
>>
>> ||
>> html input
>> type:'submit';
>> value:'Collect Input Field Values';
>> onClick:[selfcollectValues ]
>>
>>
>> collectValues
>> (('#myForm1'asJQuery get:0)checkValidity)ifTrue:[
>> "do something"
>> ^false]
>>
>> The ^false short-circuits normal posting behaviour in the form.
>>
>> However, Silk behaves differently...
>>
>> ||
>> (SilkINPUT:{'type'->'submit'.'value'->'Okay'})
>> on:'click'bind:[selfcollectValues]
>>
>> *The ^false does not short-circuit normal posting behaviour. In fact, it
>> doesn't matter whether you return true or false; it just merrily
>> continues as normal.*
>>
>> When I look at #on:bind:, it shows a significant difference from
>> TagBrush's #onClick:...
>>
>> ||
>> on:aString bind:aBlock
>> selfelement addEventListener:aString block:aBlock useCapture:false
>>
>>
>> onClick:aBlock
>> selfasJQuery bind:'click'do:aBlock
>>
>> Web is using JQuery. Could this explain the difference? Why can't I
>> short-circuit normal posting behaviour in DOMite?
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to [hidden email]
>> <mailto:[hidden email]>.
>> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.