A bit more info. I find that if I use a tall monitor and scroll the page
so that there is plenty of room for the autocomplete to fit below the input
element, the recordselect div positions correctly. It's only when I don't
have room below to fit the div it puts in the bottom value that is too
large.
looking at the code I see in the show: function on the Recordselect
(jquery/record_select.js in the gem line 214 is show:)
if (position == 'top') this.container.css('top', top);
else this.container.css('bottom', document_height - offset.top);
So it seems to me the calculation of the bottom height is not working.
Document_height is found above there as
document_height = jQuery(document).height();
Maybe that is the entire document height but you want the window height?
I'm not really an expert at client side javascript...
On Wednesday, March 25, 2015 at 3:47:26 PM UTC-7, mvargo wrote:
>
> I got it! The bottom position of the fragment is not correct. It's a
> really large value and so the drop down is there but it's off the screen
> below. I modified that bottom attribute in inspector and the box showed
> up. I will look into how the record_select gem decides where to put the
> box. Must be some kind of javascript code there that maybe gets the
> location before the page is settled or something...
>
> Details;
>
> So I have cases where I'm using record_select on the same model
> (zen_product). The first one works every time and the other fails every
> time.
>
> The form element on the javascript partial is identical for both cases and
> looks like this:
>
> <li class="form-element record_select ">
> <dl><dt><label for="record_zen_product_">Zen
> product</label></dt><dd><input autocomplete="off" class="zen_product-input
> text-input recordselect" id="record_zen_product_" name=""
> onblur="this.focused=false" onfocus="this.focused=true" type="text"><input
> type="hidden" name="record[zen_product]" value=""><script
> type="text/javascript">
> //<![CDATA[
> new RecordSelect.Single("record_zen_product_",
> "/admin/zen_products/browse", {});
> //]]>
> </script>
>
>
> </dd></dl>
> </li>
>
> When I click on the input in the success case, it inserts a chunk into the
> dom at the bottom and then positions it and it shows up. When I click on
> the failure case, it still inserts the div in the dom but it does not show
> up. Here is the top chunk of that stuff (i will leave out the <ol> with
> the choices in them. (same data in both cases)
>
> Failure case:
> <div class="record-select-container record-select-handler
> record-select-autocomplete" style="display: block; left: 219px; bottom:
> 1219px;"><div class="record-select" id="record-select-admin_zen_products">
> <form accept-charset="UTF-8"
> action="/admin/zen_products/browse?page=1&search=&update=1"
> data-remote="true" id="record-select-admin_zen_products-search"
> method="get"><div style="margin:0;padding:0;display:inline"><input
> name="utf8" type="hidden" value="✓"></div> <input autocomplete="off"
> class="text-input" id="search" name="search" type="text" value="">
> <input class="search_submit" name="commit" type="submit" value="search">
> </form>
>
> <ol>
> <li class="found">3369 zen product found</li>
> <li class="record odd" id="rs5596">
> WIR047 (6.0) - 14g FINE Silver round, dead soft wire - 1 ft
> </li>
>
> Success case:
> <div class="record-select-container record-select-handler
> record-select-autocomplete" style="display: block; left: 219px; top:
> 911px;"><div class="record-select" id="record-select-admin_zen_products">
> <form accept-charset="UTF-8"
> action="/admin/zen_products/browse?page=1&search=&update=1"
> data-remote="true" id="record-select-admin_zen_products-search"
> method="get"><div style="margin:0;padding:0;display:inline"><input
> name="utf8" type="hidden" value="✓"></div> <input autocomplete="off"
> class="text-input" id="search" name="search" type="text" value="">
> <input class="search_submit" name="commit" type="submit" value="search">
> </form>
> <ol>
> <li class="found">3369 zen product found</li>
> <li class="record odd" id="rs5596">
> WIR047 (6.0) - 14g FINE Silver round, dead soft wire - 1 ft
> </li>
>
>
> On Wednesday, March 25, 2015 at 12:53:26 AM UTC-7, Sergio Cambra wrote:
>>
>> Can you check css properties for that record-select div with inspector?
>> Is there any display: none property?
>>
>>
>>
>> El Martes, 24 de marzo de 2015 10:20:03 mvargo escribió:
>>
>> > No JS errors. The code executes successfully. The call to
>>
>> > RecordSelect.render_page... does not create an error. I copied the line
>>
>> > from the Network request and pasted it in the console and it executes. I
>>
>> > opened the gem and found this
>>
>> >
>>
>> > RecordSelect.render_page = function(record_select_id, page) {
>>
>> > jQuery('#' + record_select_id + ' ol').first().replaceWith(page);
>>
>> > };
>>
>> >
>>
>> > I did the jquery selector on the console and it is finding the element.
>> I
>>
>> > think the problem has already occurred so the dom modification is fine,
>> the
>>
>> > css was not tweaked earlier so the drop down is not visible.
>>
>> >
>>
>> > That happens when the input gets focus and it calls
>>
>> >
>>
>> > browse?search=
>>
>> >
>>
>> > I see the partial (not javascript but html fragment) of the form with
>> the
>>
>> > <ol> beneath it from the network return but that does not display on the
>>
>> > screen in the error case. I'm not sure what is catching that
>>
>> > browse?search= return but that is where the error happens.
>>
>> >
>>
>> > One other point is the same controller allows update on existing
>> records.
>>
>> > Those work. It's only the create with a blank input that creates the
>>
>> > problem.
>>
>> >
>>
>> > This is the top of that fragment
>>
>> >
>>
>> > <div class="record-select" id="record-select-admin_zen_products">
>>
>> > <form accept-charset="UTF-8"
>>
>> > action="/admin/zen_products/browse?page=1&search=&update=1"
>>
>> > data-remote="true" id="record-select-admin_zen_products-search"
>>
>> > method="get"><div style="margin:0;padding:0;display:inline"><input
>>
>> > name="utf8" type="hidden" value="✓" /></div> <input
>>
>> > autocomplete="off" class="text-input" id="search" name="search"
>> type="text"
>>
>> > value="" />
>>
>> > <input class="search_submit" name="commit" type="submit" value="search"
>> />
>>
>> > </form>
>>
>> >
>>
>> > <ol>
>>
>> > <li class="found">3345 zen product found</li>
>>
>> > <li class="record odd" id="rs5596">
>>
>> > WIR047 (0.0) - 14g FINE Silver round, dead soft wire - 1 ft
>>
>> > ...
>>
>> > lots more
>>
>> >
>>
>> > On Tuesday, March 24, 2015 at 1:56:01 AM UTC-7, Sergio Cambra wrote:
>>
>> > > Do you get any JS error on web inspector console?
>>
>> > >
>>
>> > > El Lunes, 23 de marzo de 2015 12:47:09 mvargo escribió:
>>
>> > > > I am having similar erratic behavior with the record_select
>> feature. The
>>
>> > > >
>>
>> > > > issue is that I can see the calls to the browse function on the
>>
>> > >
>>
>> > > controllers
>>
>> > >
>>
>> > > > and I see the return with the javascript to call
>>
>> > > >
>>
>> > > > RecordSelect.render_page('record-select-admin_zen_products...
>>
>> > > >
>>
>> > > > but the UI does not show up. I don't see an error in the javascript
>>
>> > > >
>>
>> > > > console either.
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > It does not happen all the time. The site I'm working on was up for
>> a
>>
>> > >
>>
>> > > week
>>
>> > >
>>
>> > > > and being used every day and then started to fail. Feels like a
>> client
>>
>> > > >
>>
>> > > > side timing issue.
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > I upgraded to latest jQuery and did a bundle update so have new
>> active
>>
>> > > >
>>
>> > > > scaffold.
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > Any ideas?
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > Gemfile:
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > gem 'rails', '3.2.21'
>>
>> > > >
>>
>> > > > gem 'mysql2'
>>
>> > > >
>>
>> > > > gem 'active_scaffold'
>>
>> > > >
>>
>> > > > ...
>>
>> > > >
>>
>> > > > gem 'recordselect'
>>
>> > > >
>>
>> > > > ...
>>
>> > > >
>>
>> > > > gem 'jquery-rails'
>>
>> > > >
>>
>> > > > gem 'jquery-ui-rails'
>>
>> > > >
>>
>> > > > # To support jquery-tools, but not included in admin ux
>>
>> > > >
>>
>> > > > gem 'jquery-migrate-rails'
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > Gemfile.lock extracts
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > active_scaffold (3.4.18.1)
>>
>> > > >
>>
>> > > > rails (>= 3.2.18, < 5)
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > recordselect (3.4.4)
>>
>> > > >
>>
>> > > > rails (>= 3.1.3)
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > jquery-rails (3.1.2)
>>
>> > > >
>>
>> > > > railties (>= 3.0, < 5.0)
>>
>> > > >
>>
>> > > > thor (>= 0.14, < 2.0)
>>
>> > > >
>>
>> > > > jquery-ui-rails (5.0.3)
>>
>> > > >
>>
>> > > > railties (>= 3.2.16)
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > admin.js.erb
>>
>> > > >
>>
>> > > >
>>
>> > > >
>>
>> > > > //= require jquery
>>
>> > > >
>>
>> > > > //= require jquery-ui
>>
>> > > >
>>
>> > > > //= require jquery_ujs
>>
>> > > >
>>
>> > > > //= require jquery.ui.nestedSortable
>>
>> > > >
>>
>> > > > //= require sortable_tree/initializer
>>
>> > > >
>>
>> > > > //= require active_scaffold
>>
>> > > >
>>
>> > > > //= require record_select
>>
>> > > >
>>
>> > > > On Tuesday, December 30, 2014 at 4:27:29 PM UTC-8, coalex wrote:
>>
>> > > > > Hey Serg,
>>
>> > > > >
>>
>> > > > > I wanted to have an autocomplete field on a few forms where the
>> drop
>>
>> > >
>>
>> > > downs
>>
>> > >
>>
>> > > > > are getting too long.
>>
>> > > > >
>>
>> > > > > So...
>>
>> > > > >
>>
>> > > > > I got recordselect working, but the list of options do not
>> dynamically
>>
>> > > > >
>>
>> > > > > update as I type in the form field.
>>
>> > > > >
>>
>> > > > > There are no obvious errors in the console.
>>
>> > > > >
>>
>> > > > > Any ideas, Thank you!!
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > Started GET "/locationtypes/browse?search=" for 127.0.0.1 at
>>
>> > > > > 2014-12-30
>>
>> > > > >
>>
>> > > > > 17:22:05 -0700
>>
>> > > > >
>>
>> > > > > Processing by LocationtypesController#browse as */*
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > Parameters: {"search"=>""}
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > (1.0ms) SELECT COUNT(*) FROM "locationtypes"
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > Rendered
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > .../gems/recordselect-d5ed9fff0efc/app/views/record_select/_
>>
>> > >
>>
>> > > search.html.er
>>
>> > >
>>
>> > > > > b
>>
>> > > > >
>>
>> > > > > (1.0ms)
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > Locationtype Load (2.0ms) SELECT "locationtypes".* FROM
>>
>> > > > > "locationtypes"
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>>
>> > > > > ORDER BY name LIMIT 12 OFFSET 0
>>
>> > > > >
>>
>> > > > >
>>
>> > > > >
>> ...
>
>
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.