check this (sorry, some parts are in russian)
http://yoga.u4388.citrine.vps-private.net/blogs

the first exposed select is Filter, the second one is Sort.

using exposed Filter, the ajax is working. Using exposed Sort, it doesn't.

I'm doing something bad?

thank u and sorry for my english.

Files: 
CommentFileSizeAuthor
#102 better_exposed_filters-links-ajax-1268150-102.patch8.86 KBrocket_nova
Test request sent.
[ View ]
#101 better_exposed_filters-links-ajax-1268150-101.patch8 KBrocket_nova
Test request sent.
[ View ]
#99 better_exposed_filters-links-ajax-1268150-99.patch8.69 KBPlacinta
Test request sent.
[ View ]
#92 better_exposed_filters-links_AJAX-1268150-92.patch7.99 KBberliner
Test request sent.
[ View ]
#82 filter_links_ajax.patch4.69 KBPlacinta
Test request sent.
[ View ]
#81 better_exposed_filters-links_AJAX-1268150-81.patch3.23 KBberliner
Test request sent.
[ View ]
#80 better_exposed_filters-links_AJAX-1268150-80.patch3.2 KBberliner
Test request sent.
[ View ]
#77 better_exposed_filters-links_AJAX-1268150-77.patch3.92 KBjeffschuler
Test request sent.
[ View ]
#77 interdiff.txt1.11 KBjeffschuler
#76 better_exposed_filters-links_AJAX-1268150-76.patch2.96 KBjeffschuler
Test request sent.
[ View ]
#59 better_exposed_filters-1268150-59-ajax-select-as-links.patch13.58 KBtostinni
FAILED: [[SimpleTest]]: [MySQL] Failed to run tests: run-tests.sh reported no tests were found. See review log for details..
[ View ]
#55 better_exposed_filters-1268150-55-ajax-select-as-links.patch13.53 KBgapple
Test request sent.
[ View ]
#54 better_exposed_filters-1268150-54-ajax-select-as-links.patch13.45 KBgapple
Test request sent.
[ View ]
#53 better_exposed_filters-1268150-53-ajax-select-as-links.patch13.68 KBgapple
Test request sent.
[ View ]
#46 bef_select_as_links-1268150-46.patch2.91 KBLiam McDermott
Test request sent.
[ View ]
#41 bef_select_as_links-1268150-41.patch3 KBPapaGrande
Test request sent.
[ View ]
#37 1268150_ajax_bef_links_36.patch3.44 KBleschekfm
Test request sent.
[ View ]
#35 1268150_ajax_bef_links_35.patch2.69 KBHydra
Test request sent.
[ View ]
#34 1268150_ajax_bef_links_34.patch2.53 KBdawehner
Test request sent.
[ View ]
#33 1268150_ajax_bef_links_32.patch2.52 KBHydra
Test request sent.
[ View ]
#26 1268150_ajax_bef_links_26.patch2.46 KBslashrsm
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1268150_ajax_bef_links_26.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#24 bef_select_as_links-1268150-24.patch2.36 KBtrogels
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch bef_select_as_links-1268150-24.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#20 bef_select_as_links-1268150-20.patch2.4 KBBrian Altenhofel
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#19 bef_exposed_filters_links-1268150-19.png110.38 KBBrian Altenhofel
#10 select-as-links-ajax-enabled-1268150.patch2.38 KBleschekfm
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch select-as-links-ajax-enabled-1268150_0.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#8 select-as-links-ajax-enabled-1268150.patch2.27 KBleschekfm
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch select-as-links-ajax-enabled-1268150.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Comments

I'm also having this problem. When filters are set as links and ajax is enabled clicking a link fires off a new page reload instead of an ajax update of my view.

Assigned:Unassigned» mikeker
Status:Active» Postponed

The Links option is not going to be compatible with AJAX refreshes as this is the difference between a GET and a POST. (See #1137720, as well). In short, we can't easily stack up all the clicks and wait until the user hits the Apply button before sending them off to Views.

It may be possible to wire the links to work with the Autosubmit option, but that's going to require a patch for CTools. In that case, since we'd be reacting on a single filter change, it could work with AJAX updating of the results.

I can look into that once we've sorted out the GET vs. POST issue.

Very interested in this possibility - subscribing.

I'm also interested because when you use link formatting within a quicktabs block, it breaks. Kindof a bummer.

Question: could we simply convert these from anchor 'a' links to 'button' html tags? They can still be themed to look like normal anchor tags, but be a form submit versus a link and thus getting around the post/get issue.

Regardless, I'm going to have to come up with a work around as I'm not sure I'll have enough client time to tackle this one. But if there is an easy fix, I'm all ears.

Rick I think some mobile browsers might treat the button element in a different way causing annoying styling issues, but I like your thinking.

Hey Leex. I know there are some CSS libraries that strip all browser specific styling and then allow for a uniform look and feel across all browsers. Sexybuttons comes to mind as one of them.

I already found a different solution around this. But I think this could still be a great solution if it could be implemented!

Status:Postponed» Needs review
StatusFileSize
new2.27 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch select-as-links-ajax-enabled-1268150.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Hi,
I made a temporary solution for the ajax problem.
In the theming function I not only print out the links but also the normal select list. When a link is hit the same value is set inside the select list. The page load is prevented but the ajax request is triggered.
At this point of development it is mandatory to uncheck the autosubmit option.

This is a very ugly hack but it works. Nonetheless not that bad for just an hour of work.

Please test the patch.

Status:Needs review» Needs work

The last submitted patch, select-as-links-ajax-enabled-1268150.patch, failed testing.

StatusFileSize
new2.38 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch select-as-links-ajax-enabled-1268150_0.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Hm, the netbeans git integration seems to use an old patch style. So I made a new patch manually.

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, select-as-links-ajax-enabled-1268150.patch, failed testing.

Can anybody point me in the right direction, where to find information on how to change the patch format or at least to verify which patch format I'm using? The only info I could find on this is that the -p0 format isn't supported any more.

Hello,

did you get this working
i'm trying to get it working, but i can't
the patch does not work
could you send / host the patched module , so i can test it

thank you very much

Version:7.x-3.0-beta1» 7.x-3.x-dev

Sorry i forgot to mention that the patch is against dev...

Thanks, it works

#12 says the patch failed testing. How do I know I can use it then? Thanks.

As the error message states the patch probably failed testing because of the patch format used. I would change it but don't know how to do it. Nonetheless this shouldn't be a problem.

How do I know I can use it then?

A hint could be that joachim desarmenien said that it solved the problem for him.
Furthermore you could for example try to apply it and see if it works ;)

If you want to know if you should use this on a production site have a look at #8

Please give feedback if it works for you.

StatusFileSize
new110.38 KB

It works for filters that have been set as links, but stops exposed sorts from working.

See attached screenshot.

StatusFileSize
new2.4 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

This patch modifies the patch in #10 to only hide the SELECT tags that are inside .bef-select-as-links.

Status:Needs work» Needs review

/me forgot to change issue status

I tried your patch both to 3.x-dev and directly on the git repository, but could not apply it. Could you reroll it?

@Brian Altenhofel Your patch works like a charm (3.x-dev)! Thank you.

Version:7.x-3.x-dev» 7.x-3.0-beta1
Assigned:mikeker» Unassigned
StatusFileSize
new2.36 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch bef_select_as_links-1268150-24.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

rerolling patch to 7.x-3.0-beta1

Status:Needs review» Reviewed & tested by the community

Confirming that it works. I think we can call this RTBC.

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new2.46 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1268150_ajax_bef_links_26.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Hm... lets rather hide submit button in a way that leaves throbber visible. It is much better from UX aspect.

Version:7.x-3.0-beta1» 7.x-3.x-dev

I applied the patch in #26. The submit button is hidden, but I'm redirected to my homepage when I click any of the links.

I'm running b.e.f. 7.x-3.x-dev, views 7.x-3.3. Does this ring a bell?

Ajax filters are working for me with the patch from #26!

Please disregard my previous post -- my issue was not related to better exposed filters. My view was loaded as a content pane. Once I set "Use panel path" to yes, the form was properly configured and I was no longer redirected. For anyone else reading this with the same issue, see #215927: A view with exposed filters inside a panel for more info.

It looks like the current DEV, 7.x-3.0-beta1+33-dev, breaks this patch. I'm successfully using it with 7.x-3.0-beta1+29-dev.

Title:Ajax doesnt work with BEF Sort LinksAjax doesnt work with BEF Links
Status:Needs review» Needs work

Thanks to everyone working on this issue! (Adjusting the title as this impacts all select-as-link options).

I like the idea of using a sidecar element, but I'm concerned about using a select element for cases where Javascript is not enabled. In those cases, the user will get both a select element and a list of links. Can we do this with a hidden element instead?

I haven't had much time to give to the BEF issue queue recently -- and I apologize for that -- if anyone is able to reroll this patch using a hidden form element, it would be much appreciated. Otherwise, I'll get to it as soon as I can...

Status:Needs work» Needs review

Well here is a reroll of the patch in #26. As far as I can tell, it Doe's not fix the problem. I'm using a BEF with links to filter trough taxonomy terms on nodes. Select works just fine, but links don't even use ajax. This patch adds something ajaxlike to the links, but this is not working yet.

StatusFileSize
new2.52 KB
Test request sent.
[ View ]

Yeah, forgot the patch :P

StatusFileSize
new2.53 KB
Test request sent.
[ View ]

So the actual problem seems to be that the ajax submit has the following post data:

tid 4
tid All
view_...

so at the end views only sees $_POST['tid'] == 'All' even the tid = 4 link got clicked.

I'm not really sure what causes this behavior but it might be related to the way links in a 'get' form acts.

This patch just did some general cleanup of the patch.

StatusFileSize
new2.69 KB
Test request sent.
[ View ]

Okay, this was a good clue, thanks dawehner! The tid value in $_POST came from a hidden input field. Of course when we use ajax, we have to adjust the value onclick. This patch should do the job.

Status:Needs review» Needs work

One problem: this patch hides the submit button on non-AJAX-enabled views.

StatusFileSize
new3.44 KB
Test request sent.
[ View ]

I rerolled the patch against the latest dev and removed the obsolete hiding of the submit button.

Please review :)

Status:Needs work» Needs review

Shouldn't better_exposed_filters_exposed_form_plugin be using #attached to put the JS on the form?

#37 patch works fine!

Indeed, I think it is better to use #attached than drupal_add_js() :

<?php
$form
['#attached']['js'][] = drupal_get_path('module', 'better_exposed_filters') . '/better_exposed_filters.js';
?>

StatusFileSize
new3 KB
Test request sent.
[ View ]

#37 worked for me so I rerolled it with @dolu's and @drewish's suggestions about using #attached.

Patch in #41 worked for me! Thank you!

Works here as well, thank you for the re-roll @PapaGrande

Status:Needs review» Reviewed & tested by the community

I think this is patch is finally ready.

First i need to say that im new to drupal world but i it was love at first sight!(i may no't know the best way to use to use things)

i think my solution is better the #41 will give bugs if u use more then one filter of this type and it dosen;t include support for multiple options
my version adds a class "selected" to the links that are selected so you can css them like you should

as i mentioned im new in drupal and i don't know how to upload pach files and things i will recreate it manualy so some1 please appaly this pach and share it with others

+++ b/better_exposed_filters.js
     }                   // attach: function() {
   };                    // Drupal.behaviors.better_exposed_filters = {

+  Drupal.behaviors.better_exposed_filters_select_as_links = {
+    attach: function(context,settings) {
+      console.log($(settings));
+      $.each(Drupal.settings.better_exposed_filters.bef_links, function(i, sliderDefaults) {
+    if(!$("#" + sliderDefaults.viewId + " #edit-"+i+"-wrapper").length){
+           i=i.replace(/_/g,"-");
+        }
+       $("#" + sliderDefaults.viewId + " #edit-"+i+"-wrapper").once(function() {
+          sliderDefaults.options = $(this).find('select option');
+
+          $(this).find('.form-type-bef-link a').each(function(key,link){
+            $(sliderDefaults.options).each(function(key,option ){
+              if($(option).text()==$(link).text()&&$(option).attr('selected')){
+                $(link).addClass('selected');
+              }
+            });
+
+            $(link).click(function(event) {
+              console.log(sliderDefaults.options);
+              event.preventDefault();
+              text = $(link).text();
+              if(!sliderDefaults.multiple){
+                $(sliderDefaults.options).removeAttr('selected');
+                console.log( $(sliderDefaults.options));
+              }
+                console.log('filter');
+              sliderDefaults.options.filter(function() {
+                if(!sliderDefaults.multiple){
+                 if($(this).text() == text)
+                   {console.log($(this));
+                  return true;
+                 }return false;
+                }
+
+                if( $(this).text() == text){
+                  if(!$(this).attr('selected')){
+                    return true;
+                  }
+                  $(this).removeAttr('selected');
+                }
+                return false;
+
+              }).attr('selected', 'true');
+
+            // submit the form
+              $('.views-exposed-widgets .views-submit-button input').click();
+            });
+          })
+
+        });
+      })
+    }
+
+  };
   /*
    * Helper functions
+++ b/better_exposed_filters.theme
   );
   return '<div class="bef-select-as-links">'
+    . theme('select', array('element' => $vars['element']))
     . theme('form_element', array('element' => $properties))
     . '</div>';
}
+++ b/better_exposed_filters_exposed_form_plugin.inc
         case 'bef_links':
           $show_apply = TRUE;
-
+        $data = array(
+              'bef_links' => array(
+                  $field_id => array(
+                      'multiple' =>!empty($form[$field_id]['#multiple']),
+                      'id' => $field_id,
+                      'viewId' => $form['#id'],
+                  ),
+              ),
+          );
+          $form[$field_id]['#attached']['js'][] = array('data' => array('better_exposed_filters' =>$data), 'type' => 'setting');
+          drupal_add_js(drupal_get_path('module', 'better_exposed_filters') . '/better_exposed_filters.js');
           $form[$field_id]['#theme'] = 'select_as_links';
           break;

this was inspired from the bef slider plugin, as far i have tested it, it works fine with no bugs or error
but id didn't test it on your project and i only tryed with multiple fields and allow multiple values

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new2.91 KB
Test request sent.
[ View ]

Attached is a re-roll of #41, I also took the liberty of changing the Javascript function name to camel case, so it matches the other function names.

Completely untested, so changing the status back to needs review.

Also, sorry #45, I'm not sure what your requirements are and am in a bit of hurry to get a working patch, so I just grabbed #41. :)

Status:Needs review» Needs work

Liam, #46 didn't seem to work for me (ajax still doesn't occur).

#41 worked on my machine ;)

I have the same issue. I tried patch #41 without luck. I'm wondering if it didn't work because I am using links for the sorts.

Using patch #41, I encountered this problem: when there are two BEF with links on the same page, the filtering in the second view does not work correctly. When there is only one of them, it works as expected.
Can anyone else confirm that #41 with two BEF links creates a problem?

I found that updating to the latest dev either created a javascript error or maybe it's the mentioned Better Exposed Filters incompatibility, but once updated it caused all AJAX toggle-downs/collapsible/collapsed containers to stop working, thus making it unusable. I did not test it with any filters so there's a problem without any filter in place.

latest patch causes BEF links to not work at all.

i have a single view with page display, and exposed filters on content type, node ref, and a boolean field.

clicking the BEF links for node ref and content type does nothing. the filter is not applied.
clicking the BEF link for the boolean field causes the view results to disappear, and on reloading the page a "illegal choice" error message appears.

opening the BEF links in a new browser tab correctly applies the filters, so it's definitely an issue with the patch and not my config.

Status:Needs work» Needs review
StatusFileSize
new13.68 KB
Test request sent.
[ View ]

Here's a patch that utilizes hidden elements to store the state of the links, based on 7.x-3.0-beta3. Hopefully it's not too difficult to port the patch to the latest dev release.

This improves the behaviour of the links even without AJAX (but with Javascript still enabled), as it allows a user toggle several items without a new page loading, and then submit the resulting state only once.
Auto-submit is also supported, with the view being updated via AJAX after each click on a link.

I required #1240238: Let use toggle links on the exposed form sorts for my project, so this patch also includes changes for that issue, with a couple additional fixes.

StatusFileSize
new13.45 KB
Test request sent.
[ View ]

A small update to the patch in #53 with some refactoring of the Javascript.

StatusFileSize
new13.53 KB
Test request sent.
[ View ]

Oops. Made one bad change in #54, so ignore that patch and use this one.

Status:Needs review» Needs work

#46 doesn't work.
Since the select input elements are still rendered with conflicting name attributes, they're probably interfering.
Not sure if this is the only issue, but it's definitely one of them.

Gapple: please do not derail this issue by combining it with #1240238

I got this working with without BEF in Drupal 7.22 with Views 3.7. I described it here: https://drupal.org/node/1111712#comment-7370826

I noticed this issue thread afterwards, thought it might be helpful. I have autosubmit turned on and am using CSS:

.views-widget-filter-type_1 {
  display: none;
}

#55 worked for me, after fixing a JS bit.

You shouldn't be using .prop, as it is unsupported on the default jQuery library packed with Drupal. After changing all the .prop to .attr's, it worked quite well.

Edit: I also had to replace line 129: $hiddenElement = $('#' + ($setWrapper.parent().attr('id')) + '-hidden');to $hiddenElement = $('#' + ($setWrapper.closest('.views-exposed-widget').attr('id').replace('-wrapper', '')) + '-hidden');

StatusFileSize
new13.58 KB
FAILED: [[SimpleTest]]: [MySQL] Failed to run tests: run-tests.sh reported no tests were found. See review log for details..
[ View ]

Here is the patch from #55 including the changes from #58.
It works nicely for me, thanks a lot everyone.

What version is that patch for? I tried applying the #59 on the latest 7.x-3.x-dev (2013-Feb-25) and 3 out of 7 hunks failed as shown below:

Hunk #1 FAILED at 83.
Hunk #2 succeeded at 246 with fuzz 2 (offset 148 lines).
1 out of 2 hunks FAILED -- saving rejects to file better_exposed_filters.js.rej
patching file better_exposed_filters.theme
Hunk #1 FAILED at 445.
Hunk #2 FAILED at 473.
Hunk #3 succeeded at 605 (offset 61 lines).
2 out of 3 hunks FAILED -- saving rejects to file better_exposed_filters.theme.rej
patching file better_exposed_filters_exposed_form_plugin.inc
Hunk #1 succeeded at 72 (offset 1 line).
Hunk #2 succeeded at 567 with fuzz 2 (offset 170 lines).
Hunk #3 FAILED at 581.
Hunk #4 FAILED at 597.
Hunk #5 succeeded at 649 with fuzz 2 (offset 177 lines).
Hunk #6 succeeded at 666 with fuzz 2 (offset 178 lines).
Hunk #7 FAILED at 929.
3 out of 7 hunks FAILED -- saving rejects to file better_exposed_filters_exposed_form_plugin.inc.rej

Version:7.x-3.x-dev» 7.x-3.0-beta3

Ups, sorry I forgot the version, I made it against 7.x-3.0-beta3.

#59 works for me! big thanks

Status:Needs work» Needs review

#26: 1268150_ajax_bef_links_26.patch queued for re-testing.

Status:Needs review» Needs work

#59 worked.

For those who are unsure how to patch a module here is a good video that shows you how to do it on a mac http://www.youtube.com/watch?v=J-Db5DbCI80. Make sure you install git from https://code.google.com/p/git-osx-installer/.

Status:Needs work» Needs review

#24: bef_select_as_links-1268150-24.patch queued for re-testing.

Worked for me - thanks a lot.

This patch (#59) worked for me. Thanks, Liam McDermott, gapple, tostinin, et al!

Status:Needs review» Reviewed & tested by the community

New to Drupal so not sure about patching etc, when would you expect this patch to make it into the main code?

Hi, #59 worked for me :)

But I do have a suggestion before porting it onto the code, I suggest adding jQuery(trigger) events before and after loading the content of the ajax, so that anyone who uses javascript effects for the view, they can 'refresh' the effects codes for the new ajax elements.

Hi Guys,

Looking forward to this patch making it to the main views module. In the mean time, I have solved this issue today by doing the following:

1) Select Better Exposed Filters
2) Under BEF Settings, select checkboxes/radio buttons
3) Add some CSS to hide the radio button circles and style your filters

Now, it's not "links" but it functions the same.

Sample CSS:

.bef-select-as-radios .form-radio {
    display: none;
}
.bef-select-as-radios .form-item {
    display: inline-block;
    color: #ff0000;
    margin-right: 10px;
}
.bef-select-as-radios .form-item:hover, .bef-select-as-radios .form-item:focus {
    color: #ffff00;
    cursor: pointer;
    }

For posterity, I have also posted this as a blog post here.

Beautiful workaround! I really love "simple" tricks like this. Thanks man.

Nice Solution. Thought of that too in the first place. But then got "distracted" by the links/buttons route :)

Thanks for sharing.

Just played with this a little.

The CSS regarding the cursor didn't work in my case when setting it on the parent DIV. When setting it directly on the label it works.

.bef-select-as-radios .form-item label{
cursor: pointer;
}

Now I only need a solution to set an active state on the links. Tried it with this jQuery snippet:

$('.bef-select-as-radios .form-item').click(function(){
// remove class 'active' on current active item
$('.bef-select-as-radios .form-item.active').removeClass('active');
// add class 'active' on clicked item
$(this).addClass('active');
});

But as Views rerenders the block, the "clicked item" and the added class get exchanged.

Any suggestions on how to set/preserve an active state?

UPDATE:
This snippet should do the trick:

$(document).ajaxComplete(function(){
$('.bef-select-as-radios label.active').removeClass('active');
$('.bef-select-as-radios.form-radio').each(function(){
if( $(this).attr( "checked" ) ){
$(this).next('label').addClass('active');
}
});
});

Have a look at http://viralpatel.net/blogs/css-radio-button-checkbox-background/ for an alternative CSS-based approach that works really well, including styling for the selected radio button.

@bsarchive Nice approach.

Version:7.x-3.0-beta3» 7.x-3.x-dev
Status:Reviewed & tested by the community» Needs review
StatusFileSize
new2.96 KB
Test request sent.
[ View ]

It looks like this issue has gotten a bit derailed.

The patch in #59 is based on #53-#55, which unnecessarily included a patch from another issue that is not applicable here, (as @aaronbauman noted in #56.)

Before that, #41 appeared to be working, then #46 was an untested change only to the JS theme function name, which broke things.

This patch is therefore a re-roll of #41 -- against 7.x-3.x-dev, (where patches should always be applied.)

It's working for me, though I'm not sure about the point behind re-displaying the filter also as a select list. Setting back to Needs Review.

StatusFileSize
new1.11 KB
new3.92 KB
Test request sent.
[ View ]

Ah.

Uncaught TypeError: Cannot read property 'datepicker' of undefined

Was stopping JS execution and not running the new script.

I added a couple tests to see if Drupal.settings.better_exposed_filters exists before checking a property inside it. (Maybe since we're attaching the JS out-of-order of where it used to be, Drupal.settings.better_exposed_filters doesn't yet exist?)

Status:Needs review» Needs work

#77 patch doesn't apply

Maybe better put, the patch no longer applies.

Looks like commit 821fea3 (#1841452: Javascript error: Uncaught TypeError: Object #<Object> has no method 'datepicker') may have fixed the datepicker check I added in #77. That piece of the patch no longer applies. Maybe we should follow the same format for the slider check. Still needs a reroll and retest.

Status:Needs work» Needs review
StatusFileSize
new3.2 KB
Test request sent.
[ View ]

Patch #76 still applies. The javascript error Uncaught TypeError: Cannot read property 'datepicker' of undefined is indeed caused by a missing Drupal.settings.better_exposed_filters. The fix is easer then proposed in #77. It is sufficient to add

  case 'bef_links':
+   $bef_add_js = TRUE;
    $form['sort_bef_combine']['#theme'] = 'select_as_links';

in better_exposed_filters_exposed_form_plugin.inc

I have updated the patch #76 accordingly.

StatusFileSize
new3.23 KB
Test request sent.
[ View ]

Small update that is not necessarily related to this issue but still useful in some tweaking contexts. E.g. I'm currently working on MEFIBS - More exposed forms in blocks and I noticed the following:

+  // This is only needed to provide ajax functionality
+  Drupal.behaviors.better_exposed_filters_select_as_links = {
+    attach: function(context) {
+
+      $('.bef-select-as-links', context).once(function() {
+        var $widgets = $('.views-exposed-widgets');     <-- get all exposed forms on the page
+        // Hide the actual form elements from the user.
+        $widgets.find('.bef-select-as-links select').hide();
+        var $options = $('.bef-select-as-links select option');
+        $(this).find('a').click(function(event) {
+          // We have to prevent the page load triggered by the links.
+          event.preventDefault();
+          event.stopPropagation();
+          var text = $(this).text();
+          // Set the corresponding option inside the select element
+          $options.filter(function() {
+            return $(this).text() == text;
+          }).attr('selected', true);
+          $('.bef-new-value').val($options.filter(':selected').val());
+
+          // Submit the form.
+          $widgets.find('.views-submit-button input').click();   <-- submit each forms, though only one link has been clicked
+        });
+      });
+    }
+  };

The code actually grabs all exposed forms on the page, and once a select link has been clicked it submits each one of them. This is a problem for multiple BEF exposed forms, but also for my custom one. In general it should only submit the form that is currently clicked in.

Issue summary:View changes
StatusFileSize
new4.69 KB
Test request sent.
[ View ]

Inspired by berliner's #81 patch, I've rewritten a patch against the stable version of the module 7.x-3.0-beta3, which might be of use to someone.

Two more notes:
1) The javascript is rewritten a bit to reuse jQuery selectors, and make multiple exposed link groups to work correctly.
2) A rather un-clean way of always adding the javascript wherever the BEF filter is used. This was done because the stable version didn't have the $bef_add_js variable.

I'm new to this. But none of these work. After applying last 3 patches the BEF links don't work at all now. Simply clicking on them nothing happens.

Also I was looking for solution to make Views Quicksand work with BEF Links, but looks like not possible.

Tested #82 and it works fine.

None of these patches address *exposed sort* with ajax.

Tested #82 and it works. Thanks Placinta!

Also confirming that #82 is working

#82 is for the 7.x-3.0-beta3.
We should focus on 7.x-3.0-dev and get the patches from #77, #80 or #81 ready and committed.
If anyone could test those and give feedback that would probably be more helpful than testing against the current beta.

#82 almost brought the needed functionality, thanks for that.

One issue remains, though: the currently active bef link (or its parent) doesn't get a selected class assigned, which makes theming impossible. Without AJAX there's a selected class for the currently active parent div, with AJAX the active class is always on the first option ("-All-" in my case).

Any ideas?

Update:
putting this inside $this.find('a').click(function (event) { brought the selected classes.

// Remove all selected classes
$('.bef-select-as-links').find('.selected').removeClass('selected');
// Add selected classes to active element
$(this).parent().addClass('selected');

Not a very elegant solution. If there are multiple select-as-links filters on a page it will probably remove the selected classes from all of them. To avoid this we could also use $(this).parent().parent().find('.selected').removeClass('selected');, which looks even uglier.

I have applied patch #82 and added code from #89 (thanks to both Placinta and Daniel), but I'm facing a new issue when clicking on a sequence of links as it don't work properly without clicking on the '- Any -' option between 2 other links.

Not sure if my explanation is clear enough, but here is an example: http://chaikhana.bodhi3.com/en/destinations. Try to click on any link (Define by Type block in the right sidebar) as 'Peaks' and then 'Glaciers' and you should be able to understand what I mean.

Any idea how to solve this?

I can confirm that #82 worked for me. Thanks!

StatusFileSize
new7.99 KB
Test request sent.
[ View ]

I have taken the time to rework the last patches (basically #81 with additions from #82 and #89), adding support for active classes and making sure, that javascript handling of clicked links are only attached to the links, when ajax is actually enabled for the given view.

This patch is against the dev branch (as all patches in this issue should be.

Please stop reviewing the patch from #82, as this is no code that can be easily merged into the dev branch. So if you need working ajax with bef links, you should take the time to review the patches against dev, so that we can at some point mark this issue RTBC.

I'm not sure what the following code is used for:

  if (!empty($element['#value'])) {
    if (is_array($element['#value'])) {
      foreach ($element['#value'] as $value) {
        $output .= '<input type="hidden" class="bef-new-value" name="' . $name . '[]" value="' . $value . '" />';
      }
    }
    else {
      $output .= '<input type="hidden" class="bef-new-value" name="' . $name . '" value="' . $element['#value'] . '" />';
    }
  }

Patch above doesn't work with the latest 7.x-3.0-beta4 release (I know it should work with dev branch) but patch from 82nd comment works ok with 3.0-beta4. But it should be applied manually. If you don't want to hack module you can easily redefine theme_select_as_links() fucntion in your template.php and and "better_exposed_filters_select_as_links" behaviour in theme based js file and it works like a charm :)

Tested patch #92 against beta4, seemed to work fine. Tested only select links for taxonomies via ajax, which worked.

I've tried #92 and it was seems to work; then after some work with project it stopped to work - nothing happens now at all, except the links gets active class correctly after click. I don't have any errors thrown to firebug console. I regret that didn't exported view and module at the point when it was working well...

tested patch #92 against 7.x-3.0-beta4+6-dev, views_quicksand with ajax links = Working

Best solution ever for me. I explain myself :

My entire Drupal web site navigation is ajax based. So like you could say to yourself about me : this guy is gonna be in deep sh** if he attempt to use ajax navigation with BEF...

So this is my problem : when ajax navigate while page i get à JS error from fireBug like this :

TypeError: Drupal.settings.better_exposed_filters is undefined
      if (Drupal.settings.better_exposed_filters.datepicker &&

this error append when i left a page with BEF in it (in fact when my new page is appended/inserted in my global contener).

So found this vars are here from a kind of render module and found is inserted from better_exposed_filters_exposed_form_plugin.inc. In this file, at line 1391 & 1992 you'll found this two lines :

      drupal_add_js(array('better_exposed_filters' => $bef_js), 'setting');
      drupal_add_js(drupal_get_path('module', 'better_exposed_filters') . '/better_exposed_filters.js');

Comment them. And save. This work for me only because i have A ENTIRE AJAX NAVIGATION from ajax pages module(i know it's a stupid and painful idea).

NB : I never found a simple and easy to use way to applying .patch and is much simple to insert a cactus in is own bottom than to apply patch on french windows 8...

thank all.

Hi all,

- patch #92 against 7.x-3.0-beta4 worked

- as i needed a link title attribute for the bef rendered links, i just added a line at 555 in better_exposed_filter.theme file :

      $url = bef_replace_query_string_arg($name, $key, $multiple, FALSE, $path);
+   $link_options['attributes']['title'] = $value;
      $elem['#children'] = l($value, $url, $link_options);

So now the value is populated to link title, and pop-up on hover, usefull when using images as clickable filters

StatusFileSize
new8.69 KB
Test request sent.
[ View ]

Adding new patch based on #92, that replaces all occurrences of "_" in views name and display name, instead of just the first one.
This fixed ajax sorting to work for me.

@placinta, I have error patching #99 with 7.x-3.0-beta4+6-dev

StatusFileSize
new8 KB
Test request sent.
[ View ]

Here is a reroll of #99 against the latest 7.x-3.x-dev.

StatusFileSize
new8.86 KB
Test request sent.
[ View ]

As @aaronbauman said in #85, the solution so far does not handle exposed sort. This patch is everything in #99 plus the ability to handle exposed sort by without an exposed sort order. This patch again is against the latest 7.x-3.x-dev.

I installed the dev version and applied the patch. I still get an error:

Uncaught TypeError: Cannot read property 'dateformat' of undefined
better_exposed_filters.js?n3fbaw:94

Also getting the exact same issue as #103 atolborg

subscribing

Stumbled on this issue while searching why does not work sorting options - patch #102 solves this (sorting by pressing "a" links) for me only partially. Tested this on 2 views: on first simple test view all with default settings and filter form not in block it worked. On second production-like view with 2 filter blocks made with MEFIBS the links were present, but nothing happened after pressing them. The error may be in the link variable structure:

viewname?sort_by=nid
vs.
viewname?mefibs-form-formname-sort_by=nid

If I copy-paste link of the second view into the browser by removing "mefibs-form-formname-" part it works well.

p.s. Applied patch manually, so it may be my mistake somewhere...

@PlayfulWolf: MEFIBS integration with BEF is a separate issue, that should be addressed once this patch is finally working and committed. The main goal now should be to get this issue here fixed without regarding any additional functionality that comes from my module. I have created a follow-up issue here: #2241133: Integration with BEF Ajax links

Then this patch produces a href's for sorting which works, I could RTBC it as working, at least partially