Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    chg20
    @chg20
    @scsmash3r is better at intercooler than I am
    Eugene Esca
    @scsmash3r
    :3 Stop it you :D
    Eugene Esca
    @scsmash3r
    @Gee5ive If you're using framework, you can rely on ic-request GET/POST parameter and in your controller you can set up an empty view that only gives back the bare data without any scripts and all the other stuff you have already loaded. Or, if you need full reinit, you can indeed detach events on beforeHistorySnaphot (deactivate datatables). All in all, it's hard to investigate into code issues without the actual code itself: how is it working, how the structure is organized and so on.
    Eugene Esca
    @scsmash3r
    @chg20 There will be no debugger from the IC side at all?
    chg20
    @chg20
    The debugger should still work, it just needs to be included explicitly.
    I will update the example today
    ฿€¢₭$
    @Gee5ive
    Hey, @chg20 @scsmash3r thanks a lot for the tips. I'll be back to work on that project over this weekend and will try implementing your suggestions. Hopefully everything works out.
    Eugene Esca
    @scsmash3r

    @chg20 I've stumbled into some issue. We have Intercooler.triggerRequest() to trigger needed request or element (as it says in docs: "Triggers an intercooler request for the given element."). Ok, I have a form element (or it can be div, no matter) with some attrs like this:

    echo Html::beginTag('form', [
        'id' => 'dialogs_search',
        'ic-post-to' => Url::toRoute(['api/someroute']),
        'ic-indicator' => '#someindicator',
        'ic-trigger-from' => '.additional_triggering_class',
        'ic-target' => '#sometarget',
        'ic-select-from-response' => '#someidtoselect',
        'ic-push-url' => 'false'
    ]);
    echo 'some data';
    echo Html::endTag('form');

    The issue is that when I'm calling Intercooler.triggerRequest('#dialogs_search'), triggering by element ID, it does the request, but ignores ic-push-url.
    If I'm triggering this form from .additional_triggering_class, it works well and does not push url. But it seems that triggerRequest ignores that? Or can it be a default behaviour from form submission?...

    chg20
    @chg20
    Hmmm.
    ic-push-url=false should be the default
    Eugene Esca
    @scsmash3r
    Hmm... Okay, I did some tests on barebone page, and everything seems to work as intended. I wonder where could I sh!tcode... :D
    I've already found a workaround, using Intercooler.triggerRequest() handler to deal with data and stuff. But still can't figure out the behaviour I'm getting.
    Eugene Esca
    @scsmash3r
    Oookay, dumb me. I was using it like 'ic-push-url' => false in my code instead 'ic-push-url' => 'false' - quotes matter, yup... Doh! :D
    chg20
    @chg20
    welcome to internet programming, enjoy your stay
    Ghost
    @ghost~57e2504a40f3a6eec06671bf

    Hey guys! Could you help me, please. I have a form:

    <form id="edit-form" ic-put-to="/page/1/edit/" ic-target="#content">
      <label>
        Text: <input name="text" value="{{ text }}">
      </label>
      <button>Submit</button>
    </form>

    How can I fire an alert on success? Looks that I should attach my message to success.ic, but on what element should I apply it?

    Brendan Rehman
    @IgnitedCoder
    if you're using php then you can simply do it like so $response->headers->add('X-IC-Script', "toastr.success('Saved','Success');"); return $response; Or use whatever backend languages response headers... much cleaner.
    Christopher Pedersen
    @topherPedersen_twitter
    Hello everyone. I'm currently running into this bug where somehow the <body> of my application is getting toggled to 'overflow: hidden' when I load a new page using IntercoolerJS. Has anyone else run into this problem? I tried looking through the IntercoolerJS source code and couldn't find any code setting overflow to hidden anywhere, so I'm not sure exactly what is going on. Anyway, if anyone has any ideas or theories please let me know here, or shoot me an email: chris@topherpedersen.com
    chg20
    @chg20
    Hi @topherPedersen_twitter there shouldn't be anything intercooler-specific taht changes the overflow:hidden property
    Keyur Shah
    @keyurshah
    is anyone using intercooler in conjunction with stimulus, it seems like it could work together well for certain non-ajax functionality. and it's a little bit more lightweight than vuejs / react.
    chg20
    @chg20
    NEVER
    ;)
    Keyur Shah
    @keyurshah
    :) the challenging part is when using intercooler with a framework that you don't have full control over
    i'm trying to use with craft commerce and anything ajax related is returned as json
    i'm using the intercooler attributes to help with that, but it becomes a little more challenging when you're not in full control of the returned data
    Mark Nellemann
    @mark_nellemann_twitter
    Hi all. I'm having trouble finding a way to make intercooler submit (ic-post-to or ic-put-to) data (pref. from ic-include) as json (to a restful backend). Do anyone have an example I could find some inspiration from?
    Eugene Esca
    @scsmash3r
    @mark_nellemann_twitter You can try to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI some parameterer, that must be your JSON object, I think. RESTful backend should have some scheme on how incoming data should look like - try to rely on that probably.
    Mark Nellemann
    @mark_nellemann_twitter
    I need to http put { "name": "some name", "otherkey": "other value" } to my backend. But how can this be done with an ic-put-to ? Do I need to use ic-on-beforeSend with some custom js function ?
    Eugene Esca
    @scsmash3r
    @mark_nellemann_twitter I think you can go with http://intercoolerjs.org/attributes/ic-include.html
    ic-include='{"name": "some name", "id": 2}'
    Eugene Esca
    @scsmash3r
    Here's an example I've used (PHP):
           echo Html::button(
                        'Button text',
                        [
                            'id' => 'new-put-event',
                            'class' => 'c-button c-button--default',
                            'ic-put-to' => 'api/entity/put',
                            'ic-on-beforeTrigger' => "jQuery('body').trigger('someCustomTriggerBeforeAPISend')",
                            'ic-include' => '{"entity_name":"'.$entity['name'].'","entity_count":'.count($entities).'}',
                            'ic-push-url' => 'false',
                        ]
                    );
    ic-include is JSON string, as stated in docs. Works well :)
    Mark Nellemann
    @mark_nellemann_twitter
    @scsmash3r thanks - I'll give it a try.
    Mark Nellemann
    @mark_nellemann_twitter
    @scsmash3r I made it work without Intercooler in pure Javascript. Is there anyway to use the ic-on-beforeTrigger to call a method that returns body which intercooler wil then ic-put-to ? So I will let intercooler handle the ajax and error handling, but I need to be able to specify the content-type and body content.
    simo sentissi
    @simosentissi
    anyone here has a reference to a live app/site making use of intercoolerjs ? I am trying to gather up a mini list of sites/apps that use it for a presentation.... I did a code search in github but nothing pops as an app I can refer to online.
    Eugene Esca
    @scsmash3r

    @simosentissi My project https://outstyle.org/ uses it. It's also open-source: https://github.com/Outstyle/website
    While it's still a mess in a code, cause previous team abandoned it (and I'm currently doing some refactoring), some examples can still be found, i.e. here: https://github.com/Outstyle/website/blob/dev-unstable/frontend/views/messages/_form.php

    It goes tied with PHP Yii2 framework.

    Eugene Esca
    @scsmash3r
    @mark_nellemann_twitter I don't know, tbh. I go like this, but this is too clumsy:
    jQuery(document).on("beforeAjaxSend.ic", function(event, settings) {
    console.log(settings); // Check out what settings you have. I think you need `settings.data` object
    // Check what url you're doing request to
      if (settings.url == '/api/neededurl') {
            myparams = 'somevar=someval';
            settings.data = settings.data + '&' + myparams; // Pass some custom data after working it out
          }
    });
    Here's more complete example, also with headers and stuff: http://intercoolerjs.org/examples/modifying_requests.html
    simo sentissi
    @simosentissi
    thank you @scsmash3r !
    Peter Kung
    @PeterKung17_twitter

    hi All! Love Intercoolerjs.

    Just trying to modify the requests to parse a bearer token...

    $(function () {
    $(document).on('beforeAjaxSend.ic', function (event, ajaxSetup, elt) {

            // Add a custom HTTP header
            ajaxSetup.headers['Authorization'] = 'bearer ' + $.cookie("token");
    
    
        });
    });

    does this look right?

    chg20
    @chg20
    @PeterKung17_twitter Yep that looks right. Demo is here: http://intercoolerjs.org/examples/modifying_requests.html
    Eugene Esca
    @scsmash3r

    @chg20 Is there a way to trigger on multiple events with ic-trigger-on? Seems not working:

    <div class="test" ic-get-from="/link" ic-trigger-on="select2:select select2:unselect" ic-select-from-response="#id" ic-target="#id" ic-push-url="true" ic-indicator="#loader">

    Using this with select2 events, and it only fires on first event select2:select, but ignores second... Is there some special separator, etc.?

    Eugene Esca
    @scsmash3r

    I've found a workaround, binding an event on body:

                jQuery("body").on("someCustomEvent", function() {
                    // do something
                });
    
                $select2DropdownObj.on('select2:select', function() {
                    jQuery(this).trigger('someCustomEvent');
                });
    
                $select2DropdownObj.on('select2:unselect', function() {
                    jQuery(this).trigger('someCustomEvent');
                });

    and by setting ic-trigger-on to fire on that event. And that event is triggering from other multiple elements, where I need them. But I wonder could that be done much easier... Also it needs to be triggered on this to take an effect from ic-trigger-on (triggering on body or document has no effect).

    Eugene Esca
    @scsmash3r
                $select2DropdownObj.on('select2:select select2:unselect', function() {
                    jQuery(this).trigger('someCustomEvent');
                });
    So I can do like this ^
    jQuery allows to do so, but in ic-trigger-on that's not working.
    chg20
    @chg20
    hmm, that should work, I'll look at the code. Another work around would be to add a second div around the first w/ the second event.
    chg20
    @chg20
    yeah, the problem is that we support syntax like ic-trigger-on="click once"
    we can make that more flexible
    chg20
    @chg20
    We should support something like: "select2:select; select2:unselect" right?
    Eugene Esca
    @scsmash3r
    Yup
    chg20
    @chg20
    yeeeeeeeup
    ;)