Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using Views Slideshow in a project and I need to customize the pagerAnchorBuilder with a function like:
function (index, slide) { return '<li><a href="#">' + index + '</a></li>'; }
In views option, I set "pagerAnchorBuilder" option with the string "return '<li><a href="#">' + index + '</a></li>';
" but when the code is evaluated within views_slideshow_cycle.js with the "eval()" function, it reports an error "return not in function".
This is my Drupal.settings array:
<!--//--><![CDATA[//><!-- jQuery.extend(Drupal.settings, {"basePath":"\/cesca\/", ... ,"viewsSlideshow":{"banner_portada-block_1":{"methods":["viewsSlideshowPagerFields","viewsSlideshowControlsText","viewsSlideshowSlideCounter","viewsSlideshowCycle"],"paused":0}},"viewsSlideshowCycle":{"#views_slideshow_cycle_main_banner_portada-block_1":{"num_divs":2,"id_prefix":"#views_slideshow_cycle_main_","div_prefix":"#views_slideshow_cycle_div_","vss_id":"banner_portada-block_1","effect":"fade","transition_advanced":0,"timeout":5000,"speed":700,"delay":0,"sync":1,"random":0,"pause":1,"pause_on_click":0,"start_paused":0,"remember_slide":0,"remember_slide_days":1,"pause_when_hidden":0,"pause_when_hidden_type":"full","amount_allowed_visible":"","nowrap":0,"fixed_height":1,"items_per_slide":1,"wait_for_image_load":1,"cleartype":0,"cleartypenobg":0,"advanced_options":"{\"pager\":\".slideshow .pager\",\"pagerAnchorBuilder\":\"return '\u003cli\u003e\u003ca href=\\\"#\\\"\u003e' +index + '\u003c\/a\u003e\u003c\/li\u003e';\"}","action_advanced":0,"advanced_options_choices":"pagerAnchorBuilder","advanced_options_entry":"return '\u003cli\u003e\u003ca href=\"#\"\u003e' +index + '\u003c\/a\u003e\u003c\/li\u003e';"}},"tableHeaderOffset":"Drupal.toolbar.height"}); //--><!]]>
Comment | File | Size | Author |
---|---|---|---|
#12 | 1079960-d7-2.patch | 681 bytes | redndahead |
#10 | 1079960-d7-1.patch | 600 bytes | redndahead |
Comments
Comment #1
redndahead CreditAttribution: redndahead commenteddon't use the function wrapper. Only use the code that goes inside the function.
Comment #2
rvilarOk, but if I use only de code inside the function:
When this code is evaluated by eval() function, this returns the error "return not in function".
Comment #3
redndahead CreditAttribution: redndahead commentedWhich advanced option are you using?
Comment #4
rvilarpagerAnchorBuilder
Comment #5
rvilarChanging state
Comment #6
redndahead CreditAttribution: redndahead commentedgrr. Advanced options are a pain. I'll have to look into another way to handle methods that return values. It will probably end up having you not specify the return and setting a specific variable as the return value. It'll be an ugly hack, but at least something that will work.
Comment #7
motgioinfo CreditAttribution: motgioinfo commentedHi redndahead,
What I have to change code of rvilar
return '<li><a href="#">' + index + '</a></li>';
to? Or I just remove return statement and define new variablevar return_var = return '<li><a href="#">' + index + '</a></li>';
Comment #8
redndahead CreditAttribution: redndahead commentedIt's not fixed yet. It will more than likely be the last one.
Comment #9
redndahead CreditAttribution: redndahead commentedComment #10
redndahead CreditAttribution: redndahead commentedHere is the patch. You need to set the return value to returnVal After looking through all of jquery cycle it seems that pagerAnchorBuilder is the only one that needs this.
Comment #11
rvilarPreviously to the eval statement, you have to declare the returnVal variable, because otherwise, its scope will be global and this could be a problem
Comment #12
redndahead CreditAttribution: redndahead commentedGood catch
Comment #13
redndahead CreditAttribution: redndahead commentedThis has been committed.
Comment #15
jesss CreditAttribution: jesss commentedI'm getting the same "return not in function" error message for the timeoutFn option.
This is the demo I'm trying to recreate:
http://jquery.malsup.com/cycle/timeout.html
Comment #19
NickDickinsonWilde