Jump to content

UniURLFrame


Lahrach Hakim
 Share

Recommended Posts

Dear hakim,

 

as i said yesterday, you will create function and this function will call ajaxevent.

 

Like that :

For example it is menu html:

MenuHTML:='<div id=\"block_navigation\"><ul class=\"navigation\"><li> '+
   '<a href=\"#\" onclick=\"MyFunction(''111'');return false;\">Home</a></li>'+
  '<li><a class=\"block_navigation_submenu\" href=\"#\">Sliders <span class=\"span_main_links\">+</span></a>'+
  '<ul><li><a href=\"#\" onclick=\"MyFunction(''112'');return false;\">Level 1 </a></li><li><a href=\"#\">Level 1 </a></li></ul>'+
  '</ul></div>';
This İs function for ajaxevent
var
data:TStringList;
begin
  data:=TStringList.Create;

  data.Clear;
  data.Add('$(document).ready(function(){  ');
  data.Add(' window.MyFunction =  function MyFunction(a) { ');
  data.Add(Format('ajaxRequest(%s, "Menuclicked", ["menuid="+a]);',   [TForm(MyForm).Name+'.'+TUniHTMLFrame(self).Name]) );
  data.Add('}');
  data.Add('});');
  UniSession.AddJS(data.Text);


  FreeAndNil(data);
end;
Link to comment
Share on other sites

  • 3 months later...

Hi  !!
 
I am very happy to meet uniGUI what is realy nice web developing framework !!
 
> I am newbie in Javascript and uniGui .  
thanks for your sharing !!
> Delphi XE2 , uniGui 0.93.1.1000
 
> I have a scenario to make an mobile app using JQuery mobile in uniURLFrame of uniGui .
  ( JQ menu in index.html -> menu click -> check it on  javascript (ajaxrequest) -> contol in mainForm -> creating html for body -> show )
  * it works well in uniHTMLFrame as scenario .
 
   the reason  why i prefer to use uniURLFrame . 
 
   1.  uniURLFrame is faster than uniHTMLFrame without blinking when changing screen .
   2.  uniURLFrame can be used/put on the same form  but uniHTMLFrame only one even same project . 
 
> As you know , we can't call any event from javascript in uniURLFrame .
>  Farshad says that  There are techniques to communicate between an <iframe> and its owner. Search web for your answer.
   BTW , i don't know how to do that . 
 
Q1. Is it possible to get event from javasript on using uniURLFrame ?  

 

Q2. Can it (Hayri's code) be applied  uniURLFrame to get event ? 

 

  data.Clear;
  data.Add('$(document).ready(function(){  ');
  data.Add(' window.MyFunction =  function MyFunction(a) { ');
  data.Add(Format('ajaxRequest(%s, "Menuclicked", ["menuid="+a]);',   [TForm(MyForm).Name+'.'+TUniHTMLFrame(self).Name]) );
  data.Add('}');
  data.Add('});');
  UniSession.AddJS(data.Text);

 

Q3. can i use many uniHTMLFrame in a Form ? ( uniURLFrame can )  

 

 

thanks for helps !! 

Link to comment
Share on other sites

thanks ,

 

* case 1 : Using uniHTMLFrame  ----- it works well 

* case 2 : Using uniURLFrame    ----- it dosen't work . ( I need ur helps ) -- How can i solve this problem ? 

 

1. index.html (it's loaded in uniURLFrame )

 

<!doctype html>
<html>
<head>
    <title>My Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
 
<body>
 
       <div id="home" data-role="page">
        <div data-role="header" data-theme="c">
            <h1> Test  </h1>
            <a href=# data-icon="home" class="ui-btn-left" onclick="goMenu(0);">Login</a>
            
        </div><!-- /header -->
 
        <div data-role="content">
            <ul data-role="listview" data-inset="true" data-filter="false">
                <li  data-role="list-divider">Menu</li>
                <li><a href="#" onclick="goMenu(1000);">menu_1000</a></li>
                <li><a href="#" onclick="goMenu(2000);">menu_2000</a></li>
            </ul> 
            
        </div><!-- /content -->
 
        <div data-role="footer"  data-position="fixed" data-theme="c">
            <h4>JQuery mobile Test </h4>
        </div><!-- /footer -->
 
</body>
 
</html>

 

<script type="text/javascript">
      function goMenu(menu_id) {
         
         // not fire any event in MainForm 
         ajaxRequest( MainForm.mainURLFrame , "goMenu", ['menu_id='+menu_id]);        // Everybody 
      }
</script>
 
 
2.  To get AjaxEvent in MainForm   
 
 
procedure TMainForm.mainURLFrameAjaxEvent(Sender: TComponent;
  EventName: string; Params: TStrings);
var
    menu_id : integer  ;
    data_id : integer  ;
    search_key : String ;
 
begin
    
     if EventName='goMenu' then begin
        menu_id := StrToInt(Params.Values['menu_id']) ;
        mainmenu( menu_id );      // go to any function 
     end ;
 

end ;

 

 

 

 

 

 

 

Link to comment
Share on other sites

Thanks ganzqgy ,

 

BTW , please explain more .

 

I changed

from   ajaxRequest( MainForm.mainURLFrame , "goMenu", ['menu_id='+menu_id]);  

to      ajaxRequest( top.MainForm, "goMenu", ['menu_id='+menu_id]);

 

and  changed  

from 
 procedure TMainForm.mainURLFrameAjaxEvent(Sender: TComponent;
  EventName: string; Params: TStrings);

 

to 
procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TStrings);
begin
      showMessage( EventName ) ;
end;
 
but it dosen't work .
Link to comment
Share on other sites

UniSession.JSCode('name_'+MainForm.UniURLFrame1.name+'_'+MainForm.UniURLFrame1.JSName+'.myinput4.innerHTML="..."');

MainForm.UniURLFrame1.iframe.contentWindow.document.getElementById("中文").innerHTML="...";

MainForm.UniURLFrame1.iframe.contentWindow.fun(1,1,22,62);//function
MainForm.UniURLFrame1.iframe.contentWindow.vvv = '';//var vvv

Link to comment
Share on other sites

Hi ganzqgy 

 

> your codes are very useful . so I could understand how to send/set something into uniURLFrmae.html .  

 

< your code >

UniSession.JSCode('name_'+MainForm.UniURLFrame1.name+'_'+MainForm.UniURLFrame1.JSName+'.myinput4.innerHTML="..."');

MainForm.UniURLFrame1.iframe.contentWindow.document.getElementById("中文").innerHTML="...";

MainForm.UniURLFrame1.iframe.contentWindow.fun(1,1,22,62);//function
MainForm.UniURLFrame1.iframe.contentWindow.vvv = '';//var vvv

 

Q.

   BTW ,

   Can  i get any values from innerHTML or innerTEXT  into uniGui again ?

   to be like below .      

   

   ex)    MainForm.uniEdit1.Text := someGetfunc ( MainForm.UniURLFrame1.iframe.contentWindow.document.getElementById("中文").innerHTML )  ;

 

many thanks for  specially Delphi Developer and ganzqgy !!

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

hi,

 

function click(sender, e, eOpts)
{
 MainForm.UniMemo1.setValue(MainForm.mainURLFrame.iframe.contentWindow.document.getElementById("dyukle").innerHTML);
}

i try this. but not get value.

 

i add uniUrlFrame html properties ( (<textarea name="dyukle" id='dyukle' rows="10" cols="50">fff</textarea)

) and this code working.

 

 

but i use load uniUrlFrame with php page( mainURLFrame.url:='http://localhost/test/index.php';)

after not working. index.php is have 

<textarea name="dyukle" id='dyukle' rows="10" cols="50">fff</textarea>

sorry my english is bad.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...