hi,
i had the same problem these days .. through this, i found this
thread :)
the problem is the following:
table-plus inserts some hidden fields for all parameters, and it also
creates a hidden field for the "search" param.
i looked at the table-plus tag source and thought that
<code>skip="page, search"</code>
should skip the search param from hidden fields creation, but
actually it doesn't.
my first solution was to extend the table-plus tag and leave out
the hidden-field stuff.
that worked as long as i didn'd use filters ...
if u have filters at work all filters loose their selection at the
moment u
execute a search, because the hidden fields are no longer present.
so that's not really a usable solution ...
i looked hidden-fields tag
<code>
<def tag="hidden-fields" attrs="fields, for-query-string, skip"><%=
pairs = if for_query_string
query_params.to_a
else
.
.
.
.
%></def>
</code>
the query_params do not skip, at least not for "for_query_string" as
it is the case in table-plus search.
(don't know if this is by intension)
i modified that by changing:
query_params.to_a
to:
(query_params - comma_split(skip)).to_a
that skips the search param from being a hidden field
and the filter params are still present.
i tried that for a moment aaaaaand .. hm .. nope not finished yet :-/
problem:
the params for the filters are uri encoded
ok .. later in the hidden-fields tag it does the following:
<code>
pairs.map { |n, v| hidden_field_tag(n, v.to_s) if v && n.not_in?
(scope.form_field_names) }.compact.join("\n")
</code>
this creates the hidden-field-tags .. ok no problem (i thought) -
unescape the stuff and we're done ..
i changed the line to:
<code>
pairs.map { |n, v| hidden_field_tag(n, URI.unescpe(v.to_s)) if v &&
n.not_in?(scope.form_field_names) }.compact.join("\n")
</code>
and tada .. filter params get submitted correctly the next time u do a
search.
i tried that for a moment aaaaaand .. hm .. nope not finished yet :-/
if u do a filter after a search the parameters are corrupted ..
problem:
in a standard submit (search) "spaces" are encoded as "+".
changing a filter takes the window.location.search part and hands it
to the the prototype function toQueryParams().
by that the "+" characters are encoded as "%2B". than it sets the
location through javascript.
line 420 in hobo-rapid.js:
<code>
params =
$H(window.location.search.toQueryParams()).merge(params)
</code>
if there are any "+" in window.location.search part
it must be a regular space because otherwise it would be encoded as a
"%2B" ...
changed the line to:
<code>
params =
$H(window.location.search.replace(/\+/g,'%20').toQueryParams
()).merge(params)
</code>
that does the trick .. it pre-encodes the "+" spaces as "%20" and
proto can do it's work.
and tada .. now it REALLY should work (still trying that though :-)
but until now i didn't find any problems.
hope that helped.
maybe tom will look through that if he has some spare time.
i hope it doesn't affect other hobo parts.
but this is working for me.
the complete code if u want to copy and paste it:
put that in your application.dryml
that will override the original hidden-fields tag and the hobo-core is
untouched.
there are 2 changes to the original - 1) skip for query_params and 2)
URI.unescape ...
<code>
<def tag="hidden-fields" attrs="fields, for-query-string, skip"><%=
pairs = if for_query_string
(query_params - comma_split(skip)).to_a
else
hiddens = case fields
when '*', nil
# TODO: Need a better (i.e. extensible) way
to eleminate certain fields
this.class.column_names - ['type',
'created_at', 'updated_at'] - comma_split(skip)
else
comma_split(fields)
end
hiddens.map do |field|
val = this.send(field)
param_name = param_name_for(form_this, form_field_path
+ [field])
[param_name, val] unless val.nil? ||
field.to_sym.in?
(this.class.attr_protected) ||
(this.new_record? && val ==
this.class.column(field).default)
end.compact
end
pairs.map { |n, v| hidden_field_tag(n, URI.unescape(v.to_s)) if v
&& n.not_in?(scope.form_field_names) }.compact.join("\n")
%></def>
</code>
and in /public/javascripts/hobo-rapid.js line 419 (i think) change
that:
(i do not know how to override that .. so i changed it directly in
hobo-rapid.js.
but this is restricted to the current application anyway. this will
replace all the "+" spaces in the location.search part with "%20")
<code>
addUrlParams: function(params, options) {
params = $H(window.location.search.replace(/\+/
g,'%20').toQueryParams()).merge(params)
if (options.remove) {
var remove = (options.remove instanceof Array) ?
options.remove : [options.remove]
remove.each(function(k) { params.unset(k) })
}
return window.location.href.sub(/(\?.*|$)/, "?" +
params.toQueryString())
},
</code>
i think that's all :)
greetz
reiner23fx
On Nov 10, 8:06 pm, Edmund <[EMAIL PROTECTED]> wrote:
> Dave,
>
> Yes, I have an app which is usingtable-plusand same thing happens
> when entering asearchstring after a firstsearchhas returned
> results. When the secondsearchreturns results, the url has twosearch=
> params. Now, try doing a thirdsearchand when the results
> come back, the url shows the second and the thirdsearch= params.
> Something's not right.
>
> Since we are on the subject of the hobosearchfacility, I'd also like
> to mention that it would be great if there would be a "Case
> Sensitive"/"Case Insensitive" toggle for searches of this kind. We
> have looked into possibly hacking but it looks like it would be easier
> to make it a permanent hobo feature. ;-)
>
> Tom, what do you think?
>
> Edmund
>
> On Nov 6, 3:49 am, Dave Porter <[EMAIL PROTECTED]> wrote:
>
> > An interesting observation...
>
> > Working through Agility tutorial...
> > Up to:
> > "Improve the project page with a searchable, sortabletable"
>
> > <table-plus> works well.
>
> > Searchworks when I enter asearchstring, but when I clear what I
> > entered and click go, ( thinking this will refresh thetablewith all
> > records ) thesearchstring I entered re-appears andtable-plus
> > refreshes with the same 'found' records.
>
> > Tested in Firefox and IE
>
> > cheers, Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---