You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to pass and define configuration options to Select2
269
-
via `data-attributes` using nested (subkey) options.
270
-
271
-
Attributes need to be added to the `input_html` option in the form input.
272
-
For example you can tell Select2 how long to wait after a user
273
-
has stopped typing before sending the request:
274
-
275
-
```ruby
276
-
...
277
-
f.input(:category,
278
-
as::searchable_select,
279
-
ajax:true,
280
-
input_html: {
281
-
data: {
282
-
'ajax--delay' => 500
283
-
}
284
-
})
285
-
...
286
-
```
287
-
288
-
### Path options for nested resources
245
+
#### Path options for nested resources
289
246
290
247
Example for the following setup:
291
248
@@ -333,17 +290,62 @@ ActiveAdmin.register(Variant) do
333
290
...
334
291
f.input(:option_value,
335
292
as::searchable_select,
336
-
path_params: {
337
-
option_type_id: f.object.product.option_type_id
338
-
},
339
-
ajax: { resource:OptionValue })
293
+
ajax: {
294
+
resource:OptionValue,
295
+
path_params: {
296
+
option_type_id: f.object.product.option_type_id
297
+
}
298
+
})
340
299
...
341
300
end
342
301
end
343
302
```
344
303
345
304
This will generate the path for fetching as `all_options_admin_option_type_option_values(option_type_id: f.object.product.option_type_id)` (e.g. `/admin/option_types/2/option_values/all_options`)
346
305
306
+
#### Inlining Ajax Options in Feature Tests
307
+
308
+
When writing UI driven feature specs (i.e. with Capybara),
309
+
asynchronous loading of select options can increase test
310
+
complexity. `activeadmin-searchable_select` provides an option to
311
+
render all available options just like a normal select input while
312
+
still exercsing the same code paths including `scope` and
313
+
`text_attribute` handling.
314
+
315
+
For example with RSpec/Capybara, simply set `inline_ajax_options` true
0 commit comments