revig / revigniter

Framework for people who build websites using LiveCode
https://revigniter.com/
Apache License 2.0
28 stars 9 forks source link

rigJQuerySource path error #4

Closed mpblackman closed 8 years ago

mpblackman commented 8 years ago

Happy new year Ralf ! Running this function on an ubuntu set-up I'm getting a wrong JQuerypath. I have set tJquerySettings["useJQremotely"] to false. The function on line 212 of JQuery.lc combines rigSiteURL() with the path, with no slash between the two. Looks like it needs a slash added there? However even with an added slash it doesn't really work as this results in mysite/index.lc/assets/js.. when it should be just mysite/assets/js.. Am I understanding this wrong ? regards Martin

revig commented 8 years ago

Martin, thanks for reporting this issue which is related to URIs including "index.lc". This is fixed in the latest commit. Please check it out, should work now even if you don't remove "index.lc" from URIs using htaccess and mod_rewrite.

Happy New Year to you too!

mpblackman commented 8 years ago

Ralf, great you work fast! there is another issue, it seems I have trouble with the ' .bind('click',..' form of script that RevIgniter generates, doesn't seem to work as opposed to manually scripting with '.click' which works ok for me.

revig commented 8 years ago

Hmm... did a quick test using the following code:

rigJQopen
    rigJQeventOpen "'#testBtn'", "'click'"
        rigJQalert "'You clicked me!'"
    rigJQeventClose
rigJQclose

This generates this JavaScript code:

<script type="text/javascript">
    $(function() {
        $('#testBtn').bind('click', function(event){
            alert('You clicked me!');
        });
    });
</script>

So, this works for me. Which handler did you use to generate a .bind() statement?

mpblackman commented 8 years ago

OK I can confirm that rigJQalert works. The problem I am having is with rigJQxhRequest. I have set up a similar example to the one described in the user guide. But I've cut out the database and model and just want to return a test statement.

rigJQopen
    rigJQeventOpen "'#startbt'", "'click'"
    rigJQxhRequest "load", "test/dohandler", , , , "'#results'"  --doesn't work
        //rigJQalert "'you clicked me!'"  --works ok
    rigJQeventClose
  rigJQclose

My dohandler is in test.lc (and the handler name is listed in gControllerHandlers):

put "you clicked the button" into gData["dlist"]
 get rigLoadView("showresultsv")

Showresultsv.lc is in my view folder with only the following text [[gData["dlist"] ]]

My main view file has the following <p id="results">[[gData["dlist"] ]]</p>

And in the header:

<? return rigJQuerySource() ?> 
 [[gData["JQscript"] ]]

Rig generated the following script. When I click the button (id startbt) then nothing happens.

<script type="text/javascript">
$(function() {
$('#startbt').bind('click', function(event){
$('#results').load('http://mysite.com/index.lc/test/dohandler');
});
});
</script>

However the following direct js works. ( I'm also showing a loading gif)

<script>
$(function() {
$('#startbt').click(function(){
   $('#loading-image').show();
   $('#results').load('/index.lc/test/dohandler', function(){$('#loading-image').hide()});
   });
});
</script>
mpblackman commented 8 years ago

I think its related to the prepending of http://mysite.com/. As you can see my script doesn't have that part. Could you let the rigJQxhRequest path be accepted as an absolute path perhaps?

Another thing that might be relevant, I have my rig installation outside of the public html folder.

revig commented 8 years ago

Martin, if prepending the site URL to controller(/handler) paths in rigJQxhRequest does not work this means that the generated full site URL is not valid. On the basis of your infos this is:

http://mysite.com/index.lc/test/dohandler

What is the entry of your base site URL in config.lc? is this really "http://mysite.com/"? When you do your AJAX tests do you use an IP address whereas the entry in config.lc is a name address or vice versa?

Of course you could easily use a modified copy of the Jquery library in application/libraries. But first I would check why the generated URL is not valid because the function rigSiteURL() which returns the site URL is used all over the place. This means there are a lot of other libraries which depend on a valid site URL generated by the very same function and therefore, like the Jquery library, may not work in your installation.

mpblackman commented 8 years ago

Ralf, yes my config is http://mysite.com/ (where mysite is replaced by my actual domain) So a little more testing and I find a recipe: I can access my page in the browser either by typing www.mysite.com or just mysite.com and both work to get to my initial view page. However with www in the address bar, the Revigniter jquery load doesn't work, but it does work if I initially go to the page using just mysite.com. This probably sounds like a total noob issue (which I am really) and I guess I can manage it in any case by redirection or use of correct links.