@@ -186,3 +186,96 @@ asyncTest('returning false in form\'s submit bindings in non-submit-bubbling bro
186186
187187 setTimeout ( function ( ) { start ( ) ; } , 13 ) ;
188188} ) ;
189+
190+ asyncTest ( 'clicking on a link with falsy "data-remote" attribute does not fire ajaxyness ' , 0 , function ( ) {
191+ $ ( 'a[data-remote]' )
192+ . attr ( 'data-remote' , 'false' )
193+ . bind ( 'ajax:beforeSend' , function ( ) {
194+ ok ( false , 'ajax should not be triggered' ) ;
195+ } )
196+ . bind ( 'click' , function ( ) {
197+ return false ;
198+ } )
199+ . trigger ( 'click' ) ;
200+
201+ setTimeout ( function ( ) { start ( ) ; } , 20 ) ;
202+ } ) ;
203+
204+ asyncTest ( 'ctrl-clicking on a link with falsy "data-remote" attribute does not fire ajaxyness even if "data-params" present' , 0 , function ( ) {
205+ var link = $ ( 'a[data-remote]' ) , e ;
206+ e = $ . Event ( 'click' ) ;
207+ e . metaKey = true ;
208+
209+ link
210+ . removeAttr ( 'data-params' )
211+ . attr ( 'data-remote' , 'false' )
212+ . attr ( 'data-method' , 'POST' )
213+ . bind ( 'ajax:beforeSend' , function ( ) {
214+ ok ( false , 'ajax should not be triggered' ) ;
215+ } )
216+ . bind ( 'click' , function ( ) {
217+ return false ;
218+ } )
219+ . trigger ( e ) ;
220+
221+ e = $ . Event ( 'click' ) ;
222+ e . metaKey = true ;
223+
224+ link
225+ . removeAttr ( 'data-method' )
226+ . attr ( 'data-params' , 'name=steve' )
227+ . trigger ( e ) ;
228+
229+ setTimeout ( function ( ) { start ( ) ; } , 20 ) ;
230+ } ) ;
231+
232+ asyncTest ( 'clicking on a button with falsy "data-remote" attribute' , 0 , function ( ) {
233+ $ ( 'button[data-remote]:first' )
234+ . attr ( 'data-remote' , 'false' )
235+ . bind ( 'ajax:beforeSend' , function ( ) {
236+ ok ( false , 'ajax should not be triggered' ) ;
237+ } )
238+ . bind ( 'click' , function ( ) {
239+ return false ;
240+ } )
241+ . trigger ( 'click' ) ;
242+
243+ setTimeout ( function ( ) { start ( ) ; } , 20 ) ;
244+ } ) ;
245+
246+ asyncTest ( 'submitting a form with falsy "data-remote" attribute' , 0 , function ( ) {
247+ $ ( 'form[data-remote]:first' )
248+ . attr ( 'data-remote' , 'false' )
249+ . bind ( 'ajax:beforeSend' , function ( ) {
250+ ok ( false , 'ajax should not be triggered' ) ;
251+ } )
252+ . bind ( 'submit' , function ( ) {
253+ return false ;
254+ } )
255+ . trigger ( 'submit' ) ;
256+
257+ setTimeout ( function ( ) { start ( ) ; } , 20 ) ;
258+ } ) ;
259+
260+ asyncTest ( 'changing a select option with falsy "data-remote" attribute' , 0 , function ( ) {
261+ $ ( 'form' )
262+ . append (
263+ $ ( '<select />' , {
264+ 'name' : 'user_data' ,
265+ 'data-remote' : 'false' ,
266+ 'data-params' : 'data1=value1' ,
267+ 'data-url' : '/echo'
268+ } )
269+ . append ( $ ( '<option />' , { value : 'optionValue1' , text : 'option1' } ) )
270+ . append ( $ ( '<option />' , { value : 'optionValue2' , text : 'option2' } ) )
271+ ) ;
272+
273+ $ ( 'select[data-remote=false]:first' )
274+ . bind ( 'ajax:beforeSend' , function ( ) {
275+ ok ( false , 'ajax should not be triggered' ) ;
276+ } )
277+ . val ( 'optionValue2' )
278+ . trigger ( 'change' ) ;
279+
280+ setTimeout ( function ( ) { start ( ) ; } , 20 ) ;
281+ } ) ;
0 commit comments