silverstripe-frontend icon indicating copy to clipboard operation
silverstripe-frontend copied to clipboard

I've question

Open JStika opened this issue 11 years ago • 9 comments

Can I see somewhere working sample? I see error like this fig.

screen Is needed load jquery.ui too?

JStika avatar Aug 22 '13 07:08 JStika

What I noticed for myself, that all the following should be called ABOVE the pagination.

jQuery jQuery UI underscore.js (include frontend/javascript/underscore.js) lib.js (include framework/admin/javascript/lib.js)

ARNHOE avatar Aug 22 '13 13:08 ARNHOE

Thank you for your answer. I think, many users don't know about file and location lib.js... It'd be very good idea write to docs st. like:

public function init() { parent::init(); Requirements::javascript('framework/thirdparty/jquery-ui/jquery-ui.js'); Requirements::javascript('framework/admin/javascript/lib.js'); Requirements::javascript('AjaxPagination/javascript/jquery.ss.pagination.js'); //Requirements::javascript('AjaxPagination/javascript/jquery.ss.endles.js'); Requirements::javascript('AjaxPagination/javascript/underscore.js'); Requirements::customScript(<<<JS $('div.Ajaxpagination').sspagination({ indicatorElement: $('.pagination-indicator'), contentSelector: '.pagination-content' }); JS ); ........... }

Why is module name silverstripe-frontend? I think better name it'd be AjaxPagination (as I renamed in my project).

Good work:)

JStika avatar Aug 22 '13 14:08 JStika

I've still question. I had to rewrite (for bootstrap) template as:

templates: { main: '

    <%= inside %>
', prev: '<% if (active) { %>'+ '
  • <a href="#" data-page-number="<%= page %>"">&laquo
  • '+ '<% } else { %>'+ ''+ '<% } %>', next: '<% if (active) { %>'+ '
  • &raquo
  • '+ '<% } else { %>'+ ''+ '<% } %>', page: '<% if (current) { %>'+ '
  • <%= page %>
  • '+ '<% } else { %>'+ '
  • <%= page %>
  • '+ '<% } %>', abbrev: '
  • .…
  • ' }

    Do you know some solution how to use custom template (e. g.: options)?

    JStika avatar Aug 22 '13 14:08 JStika

    Ops. I cannot send template variable.

    JStika avatar Aug 22 '13 14:08 JStika

    Thank you.

    I've still question. I had to rewrite (for bootstrap) template as:

    templates: { main: '

      <%= inside %>
    ', prev: '<% if (active) { %>'+ '
  • <a href="#" data-page-number="<%= page %>"">&laquo
  • '+ '<% } else { %>'+ ''+ '<% } %>', next: '<% if (active) { %>'+ '
  • &raquo
  • '+ '<% } else { %>'+ ''+ '<% } %>', page: '<% if (current) { %>'+ '
  • <%= page %>
  • '+ '<% } else { %>'+ '
  • <%= page %>
  • '+ '<% } %>', abbrev: '
  • .…
  • ' }

    Do you know some solution, how to use custom template e.g.: in options?

    On Thursday 22.8.2013 15:43, ARNHOE wrote:

    What I noticed for myself, that all the following should be called ABOVE the pagination.

    jQuery jQuery UI underscore.js (include frontend/javascript/underscore.js) lib.js (include framework/admin/javascript/lib.js)

    — Reply to this email directly or view it on GitHub https://github.com/mateusz/silverstripe-frontend/issues/17#issuecomment-23090612.

    Yours sincerely - S pozdravem

    My momma always said, "Life was like a box of chocolates. You never know what you're gonna get." Moje máma vždycky říkala, "Život je jako bonboniéra. Nikdy nevíte, co dostaneš."

    -- Forrest Gump

        Jaroslav Stika (Pike)
    

    Address: Zdiarska 1/5, 040 01 Kosice, Slovakia Work Phone#: +421 55 62 62 53 839 Home Phone#: +421 09 05 52 87 68 Work eMail: [email protected] Home eMail: [email protected] ICQ#: 246 120 400

    JStika avatar Aug 22 '13 14:08 JStika

    @JStika Good point, added a note on the requirements here: https://github.com/mateusz/silverstripe-frontend#pulling-in-the-requirements, thanks!

    Regarding the templates, should be an easy job, no need to overwrite the source code! You are almost there, just use the jQuery widgets API:

        $('div.pagination').sspagination({
            contentSelector: '.content',
            templates: {
                // Insert your custom template code here.
            }
        });
    

    Have a look at the docs too: https://github.com/mateusz/silverstripe-frontend#template-customisation

    And also here, for different ways of working with underscore templates: http://underscorejs.org/#template

    mateusz avatar Aug 22 '13 22:08 mateusz

    Ah yeah, and the naming is like that because I thought there would be other SilverStripe-related widgets that would be useful in the frontend, so I didn't want to restrict this to pagination only.

    If you have any ideas for other types of widgets let me know :-)

    mateusz avatar Aug 22 '13 22:08 mateusz

    OK, thanks for your details. Are you thinking about to use https://github.com/browserstate/ajaxify instead files lib.js, jquery.ss.pagination.js, jquery.ss.endles.js, underscore.js?

    JStika avatar Aug 23 '13 05:08 JStika

    Ajaxify seems to do something else: it replaces entire page, instead of fetching just the necessary snippet? So there is no potential to hook up PJAX, and also all DOM in the body is reloaded.

    On the other hand it's a nice improvement which covers all possible scenarios and makes everything AJAXy in one shot :-) I'll think about how this could be incorporated.

    mateusz avatar Aug 28 '13 01:08 mateusz